mirror of https://github.com/zulip/zulip.git
Add muting.get_muted_topics
(imported from commit 5edb1d36ae66dfc42cf534edc452959df8306661)
This commit is contained in:
parent
8626276dc3
commit
04c6a8198a
|
@ -25,6 +25,16 @@ exports.is_topic_muted = function (stream, topic) {
|
|||
return sub_dict && sub_dict.get(topic);
|
||||
};
|
||||
|
||||
exports.get_muted_topics = function () {
|
||||
var topics = [];
|
||||
muted_topics.each(function (sub_dict, stream) {
|
||||
_.each(sub_dict.keys(), function (topic) {
|
||||
topics.push([stream, topic]);
|
||||
});
|
||||
});
|
||||
return topics;
|
||||
};
|
||||
|
||||
return exports;
|
||||
}());
|
||||
if (typeof module !== 'undefined') {
|
||||
|
|
|
@ -30,5 +30,14 @@ var muting = require('js/muting.js');
|
|||
// test unknown stream is harmless too
|
||||
muting.unmute_topic('unknown', 'java');
|
||||
assert(!muting.is_topic_muted('unknown', 'java'));
|
||||
|
||||
}());
|
||||
|
||||
(function test_get_muted_topics() {
|
||||
assert.deepEqual(muting.get_muted_topics(), []);
|
||||
muting.mute_topic('office', 'gossip');
|
||||
muting.mute_topic('devel', 'java');
|
||||
assert.deepEqual(muting.get_muted_topics().sort(), [
|
||||
['devel', 'java'],
|
||||
['office', 'gossip']
|
||||
]);
|
||||
}());
|
||||
|
|
Loading…
Reference in New Issue