diff --git a/static/js/muting.js b/static/js/muting.js index a7319b38ed..30a43c8d52 100644 --- a/static/js/muting.js +++ b/static/js/muting.js @@ -21,6 +21,9 @@ exports.unmute_topic = function (stream, topic) { }; exports.is_topic_muted = function (stream, topic) { + if (stream === undefined) { + return false; + } var sub_dict = muted_topics.get(stream); return sub_dict && sub_dict.get(topic); }; diff --git a/zerver/tests/frontend/node/muting.js b/zerver/tests/frontend/node/muting.js index 631267829a..5f60ac5d4c 100644 --- a/zerver/tests/frontend/node/muting.js +++ b/zerver/tests/frontend/node/muting.js @@ -11,6 +11,14 @@ set_global('page_params', { var muting = require('js/muting.js'); +(function test_edge_cases() { + // private messages + assert(!muting.is_topic_muted(undefined, undefined)); + + // defensive + assert(!muting.is_topic_muted('nonexistent', undefined)); +}()); + (function test_basics() { assert(!muting.is_topic_muted('devel', 'java')); muting.mute_topic('devel', 'java');