From 5686233699b557c20afacd20457535362afa14c9 Mon Sep 17 00:00:00 2001 From: bedo Date: Thu, 17 Oct 2024 13:52:16 +0300 Subject: [PATCH] message_header: Add date on every recipient bar in search_results. Fixes #31958 --- web/src/message_list_view.ts | 15 +++++++++++++++ web/templates/recipient_row.hbs | 4 ++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/web/src/message_list_view.ts b/web/src/message_list_view.ts index ee62d2b3bf..25b951ac48 100644 --- a/web/src/message_list_view.ts +++ b/web/src/message_list_view.ts @@ -106,6 +106,7 @@ export type MessageGroup = { topic_url: string | undefined; user_can_resolve_topic: boolean; visibility_policy: number | false; + always_display_date: boolean; } | { is_stream: false; @@ -114,6 +115,7 @@ export type MessageGroup = { is_private: true; pm_with_url: string; recipient_users: RecipientRowUser[]; + always_display_date: boolean; } ); @@ -425,6 +427,14 @@ 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; @@ -443,6 +453,9 @@ function populate_group_from_message( const message_group_id = _.uniqueId("message_group_"); const date = get_group_display_date(message, year_changed); + // 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(); if (is_stream) { assert(message.type === "stream"); // stream messages have string display_recipient @@ -501,6 +514,7 @@ function populate_group_from_message( topic_is_resolved, visibility_policy, all_visibility_policies, + always_display_date, }; } // Private message group @@ -520,6 +534,7 @@ function populate_group_from_message( pm_with_url: message.pm_with_url, recipient_users: get_users_for_recipient_row(message), display_reply_to_for_tooltip: message_store.get_pm_full_names(user_ids), + always_display_date, }; } diff --git a/web/templates/recipient_row.hbs b/web/templates/recipient_row.hbs index a17b7c9cce..f053a94e2c 100644 --- a/web/templates/recipient_row.hbs +++ b/web/templates/recipient_row.hbs @@ -76,7 +76,7 @@ {{/if}} - {{{date}}} + {{{date}}} {{else}} @@ -96,7 +96,7 @@ {{/tr~}} - {{{date}}} + {{{date}}} {{/if}}