From 47fad72226ef2a47b934ae91b05d91b0e6824bdf Mon Sep 17 00:00:00 2001 From: roanster007 Date: Wed, 17 Jul 2024 04:08:03 +0530 Subject: [PATCH] narrow: Fix incorrect message_view_header title in `with` operator. Previously, when a link containing the "with" operator in an incorrect narrow is loaded, it used to open the correct view with the wrong title of the message view header. This commit fixes it by re building the message view header title in case the narrow for the "with" operator has changed. --- web/src/filter.ts | 4 +++- web/src/message_view.js | 11 +++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/web/src/filter.ts b/web/src/filter.ts index 9f3ef505c6..5a90551bcd 100644 --- a/web/src/filter.ts +++ b/web/src/filter.ts @@ -1486,7 +1486,9 @@ export class Filter { } sorted_term_types(): string[] { - if (this._sorted_term_types === undefined) { + // We need to rebuild the sorted_term_types if at all our narrow + // is updated (through `with` operator). + if (this._sorted_term_types === undefined || this.narrow_requires_hash_change) { this._sorted_term_types = this._build_sorted_term_types(); } return this._sorted_term_types; diff --git a/web/src/message_view.js b/web/src/message_view.js index 67a14e8e9f..7fd6189921 100644 --- a/web/src/message_view.js +++ b/web/src/message_view.js @@ -666,6 +666,17 @@ export function show(raw_terms, opts) { // filter.try_adjusting_for_moved_with_target, and // should update the URL hash accordingly. update_hash_to_match_filter(filter, "retarget topic location"); + // Since filter is updated, we need to handle various things + // like updating the message view header title, unread banner + // based on the updated filter. + handle_post_message_list_change( + id_info, + message_lists.current, + opts, + select_immediately, + select_opts, + then_select_offset, + ); filter.narrow_requires_hash_change = false; } if (!select_immediately) {