Skip to content

Commit

Permalink
narrow: Mark messages as read when applying -is:dm filter.
Browse files Browse the repository at this point in the history
It will mark messages as read when applying -is:dm filter alone or coupled with stream and topic filters. But it will not mark messages as read when there is also search term present.

fixes #25113.
  • Loading branch information
syed-rafat committed May 8, 2023
1 parent 8447aa7 commit b5ff6e9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
21 changes: 19 additions & 2 deletions web/src/filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,22 @@ export class Filter {
if (_.isEqual(term_types, ["is-dm"])) {
return true;
}
// -is:dm excludes direct messages from all messages
if (_.isEqual(term_types, ["not-is-dm"])) {
return true;
}

// Excluding direct messages from stream and topic does not
// accomplish anything, but we are still letting user mark
// mark messages as read to be consistent with our design.

if (_.isEqual(term_types, ["stream", "not-is-dm"])) {
return true;
}

if (_.isEqual(term_types, ["topic", "not-is-dm"])) {
return true;
}

if (_.isEqual(term_types, ["is-mentioned"])) {
return true;
Expand Down Expand Up @@ -567,8 +583,9 @@ export class Filter {
is_common_narrow() {
// can_mark_messages_read tests the following filters:
// stream, stream + topic,
// is:dm, dm,
// is:mentioned, is:resolved
// is: dm, dm,
// ( -is: dm, stream + -is:dm, topic + -is:dm )
// is: mentioned, is: resolved
if (this.can_mark_messages_read()) {
return true;
}
Expand Down
6 changes: 6 additions & 0 deletions web/tests/filter.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,12 @@ test("basics", () => {
assert.ok(filter.has_operand("is", "dm"));
assert.ok(!filter.has_operand("is", "private"));

operators = [{operator: "is", operand: "dm", negated: true}];
filter = new Filter(operators);
assert.ok(!filter.contains_only_private_messages());
assert.ok(filter.can_mark_messages_read());
assert.ok(filter.supports_collapsing_recipients());

operators = [{operator: "is", operand: "mentioned"}];
filter = new Filter(operators);
assert.ok(!filter.contains_only_private_messages());
Expand Down

0 comments on commit b5ff6e9

Please sign in to comment.