Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

unread_ops: Fix channel narrow not marked unread.

Aman Agrawal5cdd17a7f124
diff --git a/web/src/filter.ts b/web/src/filter.ts
index 625866cf31f..bab337c3497 100644
--- a/web/src/filter.ts
+++ b/web/src/filter.ts
@@ -1782,4 +1782,18 @@ export class Filter {
return false;
}
+
+ get_stringified_narrow_for_server_query(): string {
+ return JSON.stringify(
+ this._terms.map((term) => {
+ if (term.operator === "channel") {
+ return {
+ ...term,
+ operand: Number.parseInt(term.operand, 10),
+ };
+ }
+ return term;
+ }),
+ );
+ }
}
diff --git a/web/src/unread_ops.ts b/web/src/unread_ops.ts
index 6419abd4d07..98fb049fe38 100644
--- a/web/src/unread_ops.ts
+++ b/web/src/unread_ops.ts
@@ -253,7 +253,7 @@ function process_newly_read_message(
export function mark_as_unread_from_here(message_id: number): void {
assert(message_lists.current !== undefined);
- const narrow = JSON.stringify(message_lists.current.data.filter.terms());
+ const narrow = message_lists.current.data.filter.get_stringified_narrow_for_server_query();
message_lists.current.prevent_reading();
// If we have already fully fetched the current view, we can
diff --git a/web/tests/filter.test.js b/web/tests/filter.test.js
index afd0e8d8203..b23dec1c550 100644
--- a/web/tests/filter.test.js
+++ b/web/tests/filter.test.js
@@ -2718,3 +2718,15 @@ run_test("can_newly_match_moved_messages", () => {
filter = new Filter([{negated: true, operator: "is", operand: "followed"}]);
assert.deepEqual(filter.can_newly_match_moved_messages("general", "test"), true);
});
+
+run_test("get_stringified_narrow_for_server_query", () => {
+ const filter = new Filter([
+ {operator: "channel", operand: "1"},
+ {operator: "topic", operand: "bar"},
+ ]);
+ const narrow = filter.get_stringified_narrow_for_server_query();
+ assert.equal(
+ narrow,
+ '[{"negated":false,"operator":"channel","operand":1},{"negated":false,"operator":"topic","operand":"bar"}]',
+ );
+});