From afe893b324ea0bdded4d218e65bb8339d903e687 Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Tue, 11 Feb 2014 13:30:45 -0500 Subject: [PATCH] Remove filter_term() shim function. The filter_term() function was supporting the transition from using tuples for search terms to using dictionaries, but now all of the JS code should be dictionary-compatible. (We had already abandoned the tuples safety net on staging, and a couple days of use have given me confidence we can pull the shim code.) The one side effect this change has is that search terms will be initialized to {} instead of []. This distinction matters when it comes to calling JSON.stringify on the search terms. (imported from commit 1fbe11011d8953dbea28c0657cbf88384d343e00) --- static/js/feature_flags.js | 1 - static/js/filter.js | 28 +++---------------- zerver/tests/frontend/node/filter.js | 3 -- zerver/tests/frontend/node/narrow.js | 4 --- .../tests/frontend/node/search_suggestion.js | 4 --- 5 files changed, 4 insertions(+), 36 deletions(-) diff --git a/static/js/feature_flags.js b/static/js/feature_flags.js index b43abcd7a1..48820624a0 100644 --- a/static/js/feature_flags.js +++ b/static/js/feature_flags.js @@ -55,7 +55,6 @@ exports.propagate_topic_edits = true; exports.summarize_read_while_narrowed = false; exports.clicking_notification_causes_narrow = true; exports.use_socket = true; -exports.remove_filter_tuples_safety_net = page_params.staging; // Ready for deprecation. exports.collapsible = false; diff --git a/static/js/filter.js b/static/js/filter.js index cb4a83d10b..f8bbb7a397 100644 --- a/static/js/filter.js +++ b/static/js/filter.js @@ -1,25 +1,5 @@ var Filter = (function () { -function filter_term(opts) { - // For legacy reasons we must represent filter_terms as tuples - // until we phase out all the code that assumes tuples. - // We are very close to removing the tuple code everywhere; for - // now, we remove the safety net on staging only. - var term = []; - - if (!feature_flags.remove_filter_tuples_safety_net) { - term[0] = opts.operator; - term[1] = opts.operand; - } - - // This is the new style we are phasing in. (Yes, the same - // object can be treated like either a tuple or a struct.) - term.operator = opts.operator; - term.operand = opts.operand; - - return term; -} - function mit_edu_stream_name_match(message, operand) { // MIT users expect narrowing to "social" to also show messages to /^(un)*social(.d)*$/ // (unsocial, ununsocial, social.d, etc) @@ -188,10 +168,10 @@ Filter.canonicalize_term = function (opts) { } // We may want to consider allowing mixed-case operators at some point - return filter_term({ + return { operator: operator, operand: operand - }); + }; }; @@ -239,7 +219,7 @@ Filter.parse = function (str) { // FIXME: Should we skip unknown operator names here? operator = parts.shift(); operand = decodeOperand(parts.join(':'), operator); - term = filter_term({operator: operator, operand: operand}); + term = {operator: operator, operand: operand}; operators.push(term); } }); @@ -247,7 +227,7 @@ Filter.parse = function (str) { if (search_term.length > 0) { operator = 'search'; operand = search_term.join(' '); - term = filter_term({operator: operator, operand: operand}); + term = {operator: operator, operand: operand}; operators.push(term); } return operators; diff --git a/zerver/tests/frontend/node/filter.js b/zerver/tests/frontend/node/filter.js index 84a9b7590e..04eda182ad 100644 --- a/zerver/tests/frontend/node/filter.js +++ b/zerver/tests/frontend/node/filter.js @@ -7,9 +7,6 @@ set_global('page_params', { email: 'hamlet@zulip.com', domain: 'zulip.com' }); -set_global('feature_flags', { - remove_filter_tuples_safety_net: false -}); var Filter = require('js/filter.js'); var _ = global._; diff --git a/zerver/tests/frontend/node/narrow.js b/zerver/tests/frontend/node/narrow.js index 1b568d1259..4b5df0d373 100644 --- a/zerver/tests/frontend/node/narrow.js +++ b/zerver/tests/frontend/node/narrow.js @@ -8,10 +8,6 @@ var Filter = global.Filter; var stream_data = global.stream_data; var _ = global._; -set_global('feature_flags', { - remove_filter_tuples_safety_net: false -}); - function set_filter(operators) { operators = _.map(operators, function (op) { return {operator: op[0], operand: op[1]}; diff --git a/zerver/tests/frontend/node/search_suggestion.js b/zerver/tests/frontend/node/search_suggestion.js index 94bb3156c4..1b9684a924 100644 --- a/zerver/tests/frontend/node/search_suggestion.js +++ b/zerver/tests/frontend/node/search_suggestion.js @@ -28,10 +28,6 @@ set_global('stream_data', { set_global('narrow', {}); -set_global('feature_flags', { - remove_filter_tuples_safety_net: false -}); - (function test_basic_get_suggestions() { var query = 'fred';