Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
message_list: Cleanup use of zhome to check for all message list.
Aman Agrawald52cce9c3a5a
diff --git a/web/src/filter.ts b/web/src/filter.tsindex 369491beea7..5e1c89da86c 100644--- a/web/src/filter.ts+++ b/web/src/filter.ts@@ -702,6 +702,11 @@ export class Filter {});}+ is_in_home(): boolean {+ // All messages view.+ return this._terms.length === 1 && this.has_operand("in", "home");+ }+is_keyword_search(): boolean {return this.has_operator("search");}diff --git a/web/src/message_list.js b/web/src/message_list.jsindex 6274ac55d17..964f60cf0fa 100644--- a/web/src/message_list.js+++ b/web/src/message_list.js@@ -474,11 +474,10 @@ export class MessageList {// all_messages_data, since otherwise unmuting a previously// muted stream won't work.//- // TODO: The zhome conditional is a bit awkward, but a check- // for whether the filter excludes muted streams wouldn't be- // correct, because other narrows can't pull from- // all_messages.- if (this.table_name === "zhome") {+ // "in-home" filter doesn't included muted stream messages, so we+ // need to repopulate the message list with all messages to include+ // the previous messages in muted streams so that update_items_for_muting works.+ if (this.data.filter.is_in_home()) {this.data.clear();this.data.add_messages(all_messages_data.all_messages());}diff --git a/web/tests/filter.test.js b/web/tests/filter.test.jsindex faef795ffc4..fd9fc085485 100644--- a/web/tests/filter.test.js+++ b/web/tests/filter.test.js@@ -1900,3 +1900,18 @@ run_test("is_spectator_compatible", () => {!Filter.is_spectator_compatible([{operator: "group-pm-with", operand: "[email protected]"}]),);});++run_test("is_in_home", () => {+ const filter = new Filter([{operator: "in", operand: "home"}]);+ assert.ok(filter.is_in_home());++ const filter2 = new Filter([{operator: "in", operand: "all"}]);+ assert.ok(!filter2.is_in_home());++ // Test home with additional terms is not all messages.+ const filter3 = new Filter([+ {operator: "in", operand: "home"},+ {operator: "topic", operand: "foo"},+ ]);+ assert.ok(!filter3.is_in_home());+});