mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 22:13:26 +00:00
Use _.all() in Filter._build_predicate.
By using _.all() instead of a for loop, we avoid a tiny bit of confusing between "break" being for a switch statement and being for the loop. (imported from commit cd6e7ff788b50f4dadce93e7f0efcb381bc59270)
This commit is contained in:
@@ -253,14 +253,9 @@ Filter.prototype = {
|
|||||||
// build JavaScript code in a string and then eval() it.
|
// build JavaScript code in a string and then eval() it.
|
||||||
|
|
||||||
return function (message) {
|
return function (message) {
|
||||||
var operand, i, index;
|
return _.all(operators, function (term) {
|
||||||
for (i = 0; i < operators.length; i++) {
|
var operand = term.operand;
|
||||||
// Inside this loop, the correct protocol for a test is to
|
switch (term.operator) {
|
||||||
// * "return false" if the value does not match
|
|
||||||
// * "break" if there is a match
|
|
||||||
// If you "return true", you circumvent all future operators
|
|
||||||
operand = operators[i].operand;
|
|
||||||
switch (operators[i].operator) {
|
|
||||||
case 'is':
|
case 'is':
|
||||||
if (operand === 'private') {
|
if (operand === 'private') {
|
||||||
if (message.type !== 'private') {
|
if (message.type !== 'private') {
|
||||||
@@ -343,10 +338,9 @@ Filter.prototype = {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// All filters passed.
|
return true;
|
||||||
return true;
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user