From f6161481819197061c7894bf6ae983f6e93b1098 Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Tue, 10 Sep 2013 15:33:59 -0400 Subject: [PATCH] Make muting case insensitive for streams and topics (imported from commit 6e731a5305a6d19896c61300aedf0fb4a387e148) --- static/js/muting.js | 6 +++--- zerver/tests/frontend/node/muting.js | 11 +++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/static/js/muting.js b/static/js/muting.js index 85d3ba3109..a7319b38ed 100644 --- a/static/js/muting.js +++ b/static/js/muting.js @@ -2,12 +2,12 @@ var muting = (function () { var exports = {}; -var muted_topics = new Dict(); +var muted_topics = new Dict({fold_case: true}); exports.mute_topic = function (stream, topic) { var sub_dict = muted_topics.get(stream); if (!sub_dict) { - sub_dict = new Dict(); + sub_dict = new Dict({fold_case: true}); muted_topics.set(stream, sub_dict); } sub_dict.set(topic, true); @@ -36,7 +36,7 @@ exports.get_muted_topics = function () { }; exports.set_muted_topics = function (tuples) { - muted_topics = new Dict(); + muted_topics = new Dict({fold_case: true}); _.each(tuples, function (tuple) { var stream = tuple[0]; diff --git a/zerver/tests/frontend/node/muting.js b/zerver/tests/frontend/node/muting.js index d3f8277651..631267829a 100644 --- a/zerver/tests/frontend/node/muting.js +++ b/zerver/tests/frontend/node/muting.js @@ -50,3 +50,14 @@ var muting = require('js/muting.js'); ['social', 'breakfast'] ]); }()); + +(function test_case_insensitivity() { + muting.set_muted_topics([]); + assert(!muting.is_topic_muted('SOCial', 'breakfast')); + muting.set_muted_topics([ + ['SOCial', 'breakfast'] + ]); + assert(muting.is_topic_muted('SOCial', 'breakfast')); + assert(muting.is_topic_muted('social', 'breakfast')); + assert(muting.is_topic_muted('social', 'breakFAST')); +}());