From adb2884d59623b03f8e12f61d04c8951a682534c Mon Sep 17 00:00:00 2001 From: Aman Agrawal Date: Tue, 1 Jul 2025 12:38:54 +0530 Subject: [PATCH] inbox_ui: Fix buggy save and restore of navigation state. The previous logic only worked correctly when user moved from inbox view to channel topic list view and vice versa. The logic failed if user moves out of inbox since then `save` state is never called and hence when restore is called, the navigation state gets reset. Fixed by also saving state when inbox is hidden. --- web/src/inbox_ui.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/web/src/inbox_ui.ts b/web/src/inbox_ui.ts index b57de6a032..cf1890aefb 100644 --- a/web/src/inbox_ui.ts +++ b/web/src/inbox_ui.ts @@ -257,6 +257,7 @@ function restore_inbox_view_state(): void { export function show(filter?: Filter): void { assert(hide_other_views_callback !== undefined); hide_other_views_callback(); + const was_inbox_already_visible = inbox_util.is_visible(); // Avoid setting col_focus to recipient when moving to inbox from other narrows. // We prefer to focus entire row instead of stream name for inbox-header. // Since inbox-row doesn't has a collapse button, focus on COLUMNS.COLLAPSE_BUTTON @@ -279,11 +280,11 @@ export function show(filter?: Filter): void { // do anything here if view for the same channel is visible. return; } - } else if (!was_inbox_channel_view && is_new_filter_channel_view) { + } else if (was_inbox_already_visible && !was_inbox_channel_view && is_new_filter_channel_view) { save_inbox_view_state(); } - if (was_inbox_channel_view) { + if (was_inbox_already_visible && was_inbox_channel_view) { save_channel_view_state(); } @@ -358,6 +359,12 @@ export function hide(): void { set_visible: inbox_util.set_visible, }); + if (inbox_util.is_channel_view()) { + save_channel_view_state(); + } else { + save_inbox_view_state(); + } + inbox_util.set_filter(undefined); }