mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 13:33:24 +00:00
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)
This commit is contained in:
@@ -55,7 +55,6 @@ exports.propagate_topic_edits = true;
|
|||||||
exports.summarize_read_while_narrowed = false;
|
exports.summarize_read_while_narrowed = false;
|
||||||
exports.clicking_notification_causes_narrow = true;
|
exports.clicking_notification_causes_narrow = true;
|
||||||
exports.use_socket = true;
|
exports.use_socket = true;
|
||||||
exports.remove_filter_tuples_safety_net = page_params.staging;
|
|
||||||
|
|
||||||
// Ready for deprecation.
|
// Ready for deprecation.
|
||||||
exports.collapsible = false;
|
exports.collapsible = false;
|
||||||
|
|||||||
@@ -1,25 +1,5 @@
|
|||||||
var Filter = (function () {
|
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) {
|
function mit_edu_stream_name_match(message, operand) {
|
||||||
// MIT users expect narrowing to "social" to also show messages to /^(un)*social(.d)*$/
|
// MIT users expect narrowing to "social" to also show messages to /^(un)*social(.d)*$/
|
||||||
// (unsocial, ununsocial, social.d, etc)
|
// (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
|
// We may want to consider allowing mixed-case operators at some point
|
||||||
return filter_term({
|
return {
|
||||||
operator: operator,
|
operator: operator,
|
||||||
operand: operand
|
operand: operand
|
||||||
});
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -239,7 +219,7 @@ Filter.parse = function (str) {
|
|||||||
// FIXME: Should we skip unknown operator names here?
|
// FIXME: Should we skip unknown operator names here?
|
||||||
operator = parts.shift();
|
operator = parts.shift();
|
||||||
operand = decodeOperand(parts.join(':'), operator);
|
operand = decodeOperand(parts.join(':'), operator);
|
||||||
term = filter_term({operator: operator, operand: operand});
|
term = {operator: operator, operand: operand};
|
||||||
operators.push(term);
|
operators.push(term);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -247,7 +227,7 @@ Filter.parse = function (str) {
|
|||||||
if (search_term.length > 0) {
|
if (search_term.length > 0) {
|
||||||
operator = 'search';
|
operator = 'search';
|
||||||
operand = search_term.join(' ');
|
operand = search_term.join(' ');
|
||||||
term = filter_term({operator: operator, operand: operand});
|
term = {operator: operator, operand: operand};
|
||||||
operators.push(term);
|
operators.push(term);
|
||||||
}
|
}
|
||||||
return operators;
|
return operators;
|
||||||
|
|||||||
@@ -7,9 +7,6 @@ set_global('page_params', {
|
|||||||
email: 'hamlet@zulip.com',
|
email: 'hamlet@zulip.com',
|
||||||
domain: 'zulip.com'
|
domain: 'zulip.com'
|
||||||
});
|
});
|
||||||
set_global('feature_flags', {
|
|
||||||
remove_filter_tuples_safety_net: false
|
|
||||||
});
|
|
||||||
|
|
||||||
var Filter = require('js/filter.js');
|
var Filter = require('js/filter.js');
|
||||||
var _ = global._;
|
var _ = global._;
|
||||||
|
|||||||
@@ -8,10 +8,6 @@ var Filter = global.Filter;
|
|||||||
var stream_data = global.stream_data;
|
var stream_data = global.stream_data;
|
||||||
var _ = global._;
|
var _ = global._;
|
||||||
|
|
||||||
set_global('feature_flags', {
|
|
||||||
remove_filter_tuples_safety_net: false
|
|
||||||
});
|
|
||||||
|
|
||||||
function set_filter(operators) {
|
function set_filter(operators) {
|
||||||
operators = _.map(operators, function (op) {
|
operators = _.map(operators, function (op) {
|
||||||
return {operator: op[0], operand: op[1]};
|
return {operator: op[0], operand: op[1]};
|
||||||
|
|||||||
@@ -28,10 +28,6 @@ set_global('stream_data', {
|
|||||||
|
|
||||||
set_global('narrow', {});
|
set_global('narrow', {});
|
||||||
|
|
||||||
set_global('feature_flags', {
|
|
||||||
remove_filter_tuples_safety_net: false
|
|
||||||
});
|
|
||||||
|
|
||||||
(function test_basic_get_suggestions() {
|
(function test_basic_get_suggestions() {
|
||||||
var query = 'fred';
|
var query = 'fred';
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user