mirror of
https://github.com/zulip/zulip.git
synced 2025-11-14 10:57:58 +00:00
filter: Remove redundant is:private operators.
If we have a pm-with, then is:private is redundant and just forces us to write confusing/verbose code in various places.
This commit is contained in:
@@ -152,7 +152,7 @@ function Filter(operators) {
|
||||
if (operators === undefined) {
|
||||
this._operators = [];
|
||||
} else {
|
||||
this._operators = this._canonicalize_operators(operators);
|
||||
this._operators = this.fix_operators(operators);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -454,6 +454,26 @@ Filter.prototype = {
|
||||
return true;
|
||||
},
|
||||
|
||||
fix_operators: function (operators) {
|
||||
operators = this._canonicalize_operators(operators);
|
||||
operators = this._fix_redundant_is_private(operators);
|
||||
return operators;
|
||||
},
|
||||
|
||||
_fix_redundant_is_private: function (terms) {
|
||||
const is_pm_with = (term) => {
|
||||
return Filter.term_type(term) === 'pm-with';
|
||||
};
|
||||
|
||||
if (!_.any(terms, is_pm_with)) {
|
||||
return terms;
|
||||
}
|
||||
|
||||
return _.reject(terms, (term) => {
|
||||
return Filter.term_type(term) === 'is-private';
|
||||
});
|
||||
},
|
||||
|
||||
_canonicalize_operators: function (operators_mixed_case) {
|
||||
return _.map(operators_mixed_case, function (tuple) {
|
||||
return Filter.canonicalize_term(tuple);
|
||||
|
||||
Reference in New Issue
Block a user