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.

message_list_view: Move "is_search_view" to narrow_state.

bedobf05694e599b
diff --git a/web/src/message_list_view.ts b/web/src/message_list_view.ts
index e679385793d..3ae62a5deed 100644
--- a/web/src/message_list_view.ts
+++ b/web/src/message_list_view.ts
@@ -428,14 +428,6 @@ function maybe_restore_focus_to_message_edit_form(): void {
}, 0);
}
-function is_search_view(): boolean {
- const current_filter = narrow_state.filter();
- if (current_filter && !current_filter.supports_collapsing_recipients()) {
- return true;
- }
- return false;
-}
-
type SubscriptionMarkers = {
bookend_top: boolean;
stream_name: string;
@@ -456,7 +448,7 @@ function populate_group_from_message(
// Each searched message is a self-contained result,
// so we always display date in the recipient bar for those messages.
- const always_display_date = is_search_view();
+ const always_display_date = narrow_state.is_search_view();
if (is_stream) {
assert(message.type === "stream");
// stream messages have string display_recipient
diff --git a/web/src/narrow_state.ts b/web/src/narrow_state.ts
index efc2ecc6cbb..36d64d9250a 100644
--- a/web/src/narrow_state.ts
+++ b/web/src/narrow_state.ts
@@ -25,6 +25,13 @@ export function search_terms(current_filter: Filter | undefined = filter()): Nar
return current_filter.terms();
}
+export function is_search_view(current_filter: Filter | undefined = filter()): boolean {
+ if (current_filter && !current_filter.supports_collapsing_recipients()) {
+ return true;
+ }
+ return false;
+}
+
export function is_message_feed_visible(): boolean {
// It's important that `message_lists.current` is the
// source of truth for this since during the initial app load,
diff --git a/web/tests/narrow_state.test.cjs b/web/tests/narrow_state.test.cjs
index 9c99fcf55b4..2fdef261ed3 100644
--- a/web/tests/narrow_state.test.cjs
+++ b/web/tests/narrow_state.test.cjs
@@ -87,6 +87,7 @@ test("narrowed", () => {
assert.ok(!narrow_state.narrowed_by_pm_reply());
assert.ok(!narrow_state.narrowed_by_topic_reply());
assert.ok(narrow_state.narrowed_by_stream_reply());
+ assert.ok(!narrow_state.is_search_view());
set_filter([["dm", "[email protected]"]]);
assert.ok(narrow_state.narrowed_to_pms());
@@ -94,6 +95,7 @@ test("narrowed", () => {
assert.ok(narrow_state.narrowed_by_pm_reply());
assert.ok(!narrow_state.narrowed_by_topic_reply());
assert.ok(!narrow_state.narrowed_by_stream_reply());
+ assert.ok(!narrow_state.is_search_view());
set_filter([
["stream", foo_stream_id.toString()],
@@ -104,6 +106,7 @@ test("narrowed", () => {
assert.ok(!narrow_state.narrowed_by_pm_reply());
assert.ok(narrow_state.narrowed_by_topic_reply());
assert.ok(!narrow_state.narrowed_by_stream_reply());
+ assert.ok(!narrow_state.is_search_view());
set_filter([["search", "grail"]]);
assert.ok(!narrow_state.narrowed_to_pms());
@@ -111,6 +114,7 @@ test("narrowed", () => {
assert.ok(!narrow_state.narrowed_by_pm_reply());
assert.ok(!narrow_state.narrowed_by_topic_reply());
assert.ok(!narrow_state.narrowed_by_stream_reply());
+ assert.ok(narrow_state.is_search_view());
set_filter([["is", "starred"]]);
assert.ok(!narrow_state.narrowed_to_pms());
@@ -118,6 +122,7 @@ test("narrowed", () => {
assert.ok(!narrow_state.narrowed_by_pm_reply());
assert.ok(!narrow_state.narrowed_by_topic_reply());
assert.ok(!narrow_state.narrowed_by_stream_reply());
+ assert.ok(narrow_state.is_search_view());
});
test("terms", () => {