Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

narrow: Mark messages as read when applying -is:dm filter. #25351

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
narrow: is_common_narrow in filter.js now extends core_filters method.
This new method has all the filters that work with both
can_mark_messages_read and is_common_narrow.

This a pre commit to prepare for changes necessary in #25351.

is_common_narrow breaks without this refactor.
  • Loading branch information
syed-rafat committed Jun 2, 2023
commit f676b9d682032428764bfad85ca1c789f8207f1c
31 changes: 21 additions & 10 deletions web/src/filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -500,10 +500,9 @@ export class Filter {
return true;
}

calc_can_mark_messages_read() {
// Arguably this should match supports_collapsing_recipients.
// We may want to standardize on that in the future. (At
// present, this function does not allow combining valid filters).
// these filters work for both
// calc_can_mark_messages_read and is_common_narrow
core_filters() {
const term_types = this.sorted_term_types();

if (_.isEqual(term_types, ["stream", "topic"])) {
Expand All @@ -514,11 +513,6 @@ export class Filter {
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.
// (in which case, is_common_narrow would also need to be modified)

if (_.isEqual(term_types, ["stream"])) {
return true;
}
Expand Down Expand Up @@ -547,6 +541,23 @@ export class Filter {
return false;
}

calc_can_mark_messages_read() {
// Arguably this should match supports_collapsing_recipients.
// We may want to standardize on that in the future. (At
// present, this function does not allow combining valid filters).

if (this.core_filters()) {
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.
// (in which case, is_common_narrow would also need to be modified)

return false;
}

can_mark_messages_read() {
if (this._can_mark_messages_read === undefined) {
this._can_mark_messages_read = this.calc_can_mark_messages_read();
Expand All @@ -569,7 +580,7 @@ export class Filter {
// stream, stream + topic,
// is:dm, dm,
// is:mentioned, is:resolved
if (this.can_mark_messages_read()) {
if (this.core_filters()) {
return true;
}
// that leaves us with checking:
Expand Down