Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
narrow: Update narrow title for undefined filter views.
Lauryn Menard7c083edb960a
diff --git a/frontend_tests/node_tests/narrow.js b/frontend_tests/node_tests/narrow.jsindex dd49c0edc55..d08cd09093f 100644--- a/frontend_tests/node_tests/narrow.js+++ b/frontend_tests/node_tests/narrow.js@@ -22,6 +22,9 @@ const compose_pm_pill = mock_esm("../../static/js/compose_pm_pill");mock_esm("../../static/js/spectators", {login_to_access() {},});+const recent_topics_util = mock_esm("../../static/js/recent_topics_util", {+ is_visible() {},+});function empty_narrow_html(title, html, search_data) {const opts = {@@ -815,10 +818,18 @@ run_test("narrow_to_compose_target PMs", ({override, override_rewire}) => {assert.deepEqual(args.operators, [{operator: "is", operand: "private"}]);});-run_test("narrow_compute_title", () => {+run_test("narrow_compute_title", ({override}) => {// Only tests cases where the narrow title is different from the filter title.let filter;+ // Recent conversations & All messages have `undefined` filter.+ filter = undefined;+ override(recent_topics_util, "is_visible", () => true);+ assert.equal(narrow.compute_narrow_title(filter), "translated: Recent conversations");++ override(recent_topics_util, "is_visible", () => false);+ assert.equal(narrow.compute_narrow_title(filter), "translated: All messages");+// Search & uncommon narrowsfilter = new Filter([{operator: "search", operand: "potato"}]);assert.equal(narrow.compute_narrow_title(filter), "translated: Search results");diff --git a/frontend_tests/node_tests/recent_topics.js b/frontend_tests/node_tests/recent_topics.jsindex f32fae6bd8d..3a88d643fbd 100644--- a/frontend_tests/node_tests/recent_topics.js+++ b/frontend_tests/node_tests/recent_topics.js@@ -102,7 +102,7 @@ mock_esm("../../static/js/user_topics", {},});const narrow = mock_esm("../../static/js/narrow", {- set_narrow_title: noop,+ update_narrow_title: noop,hide_mark_as_read_turned_off_banner: noop,handle_middle_pane_transition: noop,has_shown_message_list_view: true,diff --git a/static/js/narrow.js b/static/js/narrow.jsindex 468a1aa5bdd..f653bed3255 100644--- a/static/js/narrow.js+++ b/static/js/narrow.js@@ -119,12 +119,20 @@ 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) {+function set_narrow_title(title) {narrow_title = title;- notifications.redraw_title();}export function compute_narrow_title(filter) {+ if (filter === undefined) {+ // "All messages" and "Recent conversations" views have+ // an `undefined` filter.+ if (recent_topics_util.is_visible()) {+ return $t({defaultMessage: "Recent conversations"});+ }+ return $t({defaultMessage: "All messages"});+ }+const filter_title = filter.get_title();if (filter_title === undefined) {@@ -162,9 +170,10 @@ export function compute_narrow_title(filter) {return filter_title;}-function update_narrow_title(filter) {+export function update_narrow_title(filter) {const narrow_title_string = compute_narrow_title(filter);set_narrow_title(narrow_title_string);+ notifications.redraw_title();}export function reset_ui_state() {@@ -1007,8 +1016,7 @@ function handle_post_narrow_deactivate_processes() {widgetize.set_widgets_for_list();typing_events.render_notifications_for_narrow();message_view_header.initialize();- narrow_title = $t({defaultMessage: "All messages"});- notifications.redraw_title();+ update_narrow_title(narrow_state.filter());message_scroll.update_top_of_narrow_notices(message_lists.home);}diff --git a/static/js/recent_topics_ui.js b/static/js/recent_topics_ui.jsindex 9924d416f22..ddf22adc24d 100644--- a/static/js/recent_topics_ui.js+++ b/static/js/recent_topics_ui.js@@ -870,8 +870,7 @@ export function show() {compose_closed_ui.update_buttons_for_recent_topics();narrow_state.reset_current_filter();- const recent_topics_title = $t({defaultMessage: "Recent conversations"});- narrow.set_narrow_title(recent_topics_title);+ narrow.update_narrow_title(narrow_state.filter());message_view_header.render_title_area();narrow.handle_middle_pane_transition();pm_list.handle_narrow_deactivated();