mirror of https://github.com/zulip/zulip.git
Support operator aliases, and introduce the first, from: canonicalizing to sender:.
This also normalizes the casing of operators, which makes Sender:wdaher@humbughq.com work when it would previously give an "unknown operator" error. (imported from commit fb3f748a474e1c9c710547ae3c05a4ace86c3230)
This commit is contained in:
parent
ae31988e42
commit
1defcf5718
|
@ -10,6 +10,17 @@ function Filter(operators) {
|
|||
}
|
||||
}
|
||||
|
||||
var canonical_operators = {"from": "sender"};
|
||||
|
||||
exports.canonicalize_operator = function (operator) {
|
||||
operator = operator.toLowerCase();
|
||||
if (canonical_operators[operator] !== undefined) {
|
||||
return canonical_operators[operator];
|
||||
} else {
|
||||
return operator;
|
||||
}
|
||||
};
|
||||
|
||||
Filter.prototype = {
|
||||
predicate: function Filter_predicate() {
|
||||
if (this._predicate === undefined) {
|
||||
|
@ -85,7 +96,8 @@ Filter.prototype = {
|
|||
// We don't use $.map because it flattens returned arrays.
|
||||
$.each(operators_mixed_case, function (idx, operator) {
|
||||
// We may want to consider allowing mixed-case operators at some point
|
||||
new_operators.push([operator[0], subs.canonicalized_name(operator[1])]);
|
||||
new_operators.push([exports.canonicalize_operator(operator[0]),
|
||||
subs.canonicalized_name(operator[1])]);
|
||||
});
|
||||
return new_operators;
|
||||
},
|
||||
|
|
|
@ -46,7 +46,7 @@ function stream_matches_query(stream_name, q) {
|
|||
function describe(operators) {
|
||||
return $.map(operators, function (elem) {
|
||||
var operand = elem[1];
|
||||
switch (elem[0]) {
|
||||
switch (narrow.canonicalize_operator(elem[0])) {
|
||||
case 'is':
|
||||
if (operand === 'private') {
|
||||
return 'Narrow to all private messages';
|
||||
|
|
Loading…
Reference in New Issue