Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
recent_topics: Save offset when navigating from narrow or "all".
YashRE42c4bb181056ab
diff --git a/frontend_tests/node_tests/recent_topics.js b/frontend_tests/node_tests/recent_topics.jsindex 8155e3b7fc7..64239f61be4 100644--- a/frontend_tests/node_tests/recent_topics.js+++ b/frontend_tests/node_tests/recent_topics.js@@ -97,9 +97,10 @@ mock_esm("../../static/js/muted_topics", {return false;},});-mock_esm("../../static/js/narrow", {+const narrow = mock_esm("../../static/js/narrow", {set_narrow_title: noop,hide_mark_as_read_turned_off_banner: noop,+ has_shown_message_list_view: true,});mock_esm("../../static/js/recent_senders", {get_topic_recent_senders: () => [1, 2],@@ -338,7 +339,9 @@ function test(label, f) {});}-test("test_recent_topics_show", ({mock_template}) => {+test("test_recent_topics_show", ({mock_template, override}) => {+ override(narrow, "save_pre_narrow_offset_for_reload", () => {});+// Note: unread count and urls are fake,// since they are generated in external libraries// and are not to be tested here.diff --git a/static/js/narrow.js b/static/js/narrow.jsindex d9c6f95cac0..5624f813de7 100644--- a/static/js/narrow.js+++ b/static/js/narrow.js@@ -114,6 +114,7 @@ export function save_pre_narrow_offset_for_reload() {}export let narrow_title = "home";+export let has_shown_message_list_view = false;export function set_narrow_title(title) {narrow_title = title;@@ -292,6 +293,7 @@ export function activate(raw_operators, opts) {// populating the new narrow, so we update our narrow_state.// From here on down, any calls to the narrow_state API will// reflect the upcoming narrow.+ has_shown_message_list_view = true;narrow_state.set_current_filter(filter);const excludes_muted_topics = narrow_state.excludes_muted_topics();@@ -882,6 +884,7 @@ export function deactivate(coming_from_recent_topics = false) {}narrow_state.reset_current_filter();+ has_shown_message_list_view = true;$("body").removeClass("narrowed_view");$("#zfilt").removeClass("focused_table");diff --git a/static/js/recent_topics_ui.js b/static/js/recent_topics_ui.jsindex 7fd013cefbb..31190d6a7f6 100644--- a/static/js/recent_topics_ui.js+++ b/static/js/recent_topics_ui.js@@ -622,6 +622,10 @@ export function complete_rerender() {}export function show() {+ if (narrow.has_shown_message_list_view) {+ narrow.save_pre_narrow_offset_for_reload();+ }+if (is_visible()) {// If we're already visible, E.g. because the user hit Esc// while already in the recent topics view, do nothing.