mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 06:53:25 +00:00
refactor: Clean up can_mark_messages_read.
We now explicitly enumerate various cases, which should make it easier to change this code.
This commit is contained in:
@@ -382,13 +382,44 @@ Filter.prototype = {
|
||||
},
|
||||
|
||||
can_mark_messages_read: function () {
|
||||
return _.every(this._operators, function (elem) {
|
||||
return (_.contains(['stream', 'topic', 'pm-with'], elem.operator)
|
||||
|| elem.operator === 'is' && elem.operand === 'private'
|
||||
|| elem.operator === 'in' && elem.operand === 'all'
|
||||
|| elem.operator === 'in' && elem.operand === 'home')
|
||||
&& !elem.negated;
|
||||
});
|
||||
const term_types = this.sorted_term_types();
|
||||
|
||||
if (_.isEqual(term_types, ['stream', 'topic'])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (_.isEqual(term_types, ['pm-with'])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// TODO: Some users really hate it when Zulip marks messages as read
|
||||
// in interleaved views, so we will eventually have a setting
|
||||
// that early-exits before the subsequent checks.
|
||||
|
||||
if (_.isEqual(term_types, ['stream'])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (_.isEqual(term_types, ['is-private'])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (_.isEqual(term_types, [])) {
|
||||
// All view
|
||||
return true;
|
||||
}
|
||||
|
||||
if (this._operators.length === 1) {
|
||||
const elem = this._operators[0];
|
||||
|
||||
if (elem.operator === 'in' && !elem.negated) {
|
||||
if (elem.operand === 'home' || elem.operand === 'all') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
allow_use_first_unread_when_narrowing: function () {
|
||||
|
||||
Reference in New Issue
Block a user