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.

narrow: Hide inbox/recent views inside deactivate.

Tim Abbotteabab840e9f0
diff --git a/web/src/hashchange.js b/web/src/hashchange.js
index 37f3239a0d6..d79e88389c2 100644
--- a/web/src/hashchange.js
+++ b/web/src/hashchange.js
@@ -51,9 +51,7 @@ function maybe_hide_inbox() {
}
function show_all_message_view() {
- const coming_from_recent_view = maybe_hide_recent_view();
- const coming_from_inbox = maybe_hide_inbox();
- narrow.deactivate(coming_from_recent_view || coming_from_inbox);
+ narrow.deactivate();
// We need to maybe scroll to the selected message
// once we have the proper viewport set up
message_viewport.maybe_scroll_to_selected();
diff --git a/web/src/narrow.js b/web/src/narrow.js
index b90296cd780..606085e7ea8 100644
--- a/web/src/narrow.js
+++ b/web/src/narrow.js
@@ -972,7 +972,7 @@ function handle_post_narrow_deactivate_processes(msg_list) {
message_feed_top_notices.update_top_of_narrow_notices(msg_list);
}
-export function deactivate(message_feed_previously_hidden = false) {
+export function deactivate() {
// NOTE: Never call this function independently,
// always use browser_history.go_to_location("#all_messages") to
// activate All message narrow.
@@ -990,14 +990,22 @@ export function deactivate(message_feed_previously_hidden = false) {
*/
search.clear_search_form();
- // If we're already looking at the All messages view, exit without
- // doing any work.
- if (
- narrow_state.filter() === undefined &&
- !message_feed_previously_hidden &&
- has_visited_all_messages
- ) {
+ const coming_from_recent_view = recent_view_util.is_visible();
+ const coming_from_inbox = inbox_util.is_visible();
+
+ if (coming_from_recent_view) {
+ recent_view_ui.hide();
+ } else if (coming_from_inbox) {
+ inbox_ui.hide();
+ } else if (narrow_state.filter() === undefined && has_visited_all_messages) {
+ // If we're already looking at the All messages view, exit without
+ // doing any work.
return;
+ } else {
+ // We must instead be switching from another message view.
+ // Save the scroll position in that message list, so that
+ // we can restore it if/when we later navigate back to that view.
+ message_lists.save_pre_narrow_offset_for_reload();
}
has_visited_all_messages = true;