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.
This commit is contained in:
roanster007 2024-07-17 04:08:03 +05:30 committed by Tim Abbott
parent 125ef2a7d4
commit 47fad72226
2 changed files with 14 additions and 1 deletions

View File

@ -1486,7 +1486,9 @@ export class Filter {
} }
sorted_term_types(): string[] { 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(); this._sorted_term_types = this._build_sorted_term_types();
} }
return this._sorted_term_types; return this._sorted_term_types;

View File

@ -666,6 +666,17 @@ export function show(raw_terms, opts) {
// filter.try_adjusting_for_moved_with_target, and // filter.try_adjusting_for_moved_with_target, and
// should update the URL hash accordingly. // should update the URL hash accordingly.
update_hash_to_match_filter(filter, "retarget topic location"); 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; filter.narrow_requires_hash_change = false;
} }
if (!select_immediately) { if (!select_immediately) {