Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
narrow: Add setter for narrow_title.
Anders Kaseorg4a2f937732e8
diff --git a/frontend_tests/node_tests/recent_topics.js b/frontend_tests/node_tests/recent_topics.jsindex 4c1d11e3186..6eecc9ce001 100644--- a/frontend_tests/node_tests/recent_topics.js+++ b/frontend_tests/node_tests/recent_topics.js@@ -20,10 +20,7 @@ set_global("compose_actions", {cancel: noop,});set_global("narrow", {- narrow_title: "",-});-rewiremock("../../static/js/notifications").with({- redraw_title: noop,+ set_narrow_title: noop,});rewiremock("../../static/js/message_view_header").with({render_title_area: noop,diff --git a/static/js/narrow.js b/static/js/narrow.jsindex db13da509a0..3166d8340ed 100644--- a/static/js/narrow.js+++ b/static/js/narrow.js@@ -100,42 +100,46 @@ exports.save_pre_narrow_offset_for_reload = function () {}};+exports.narrow_title = "home";++exports.set_narrow_title = function (title) {+ exports.narrow_title = title;+ notifications.redraw_title();+};+function update_narrow_title(filter) {// Take the most detailed part of the narrow to use as the title.// If the operator is something other than "stream", "topic", or// "is", we shouldn't update the narrow titleif (filter.has_operator("stream")) {if (filter.has_operator("topic")) {- exports.narrow_title = filter.operands("topic")[0];+ exports.set_narrow_title(filter.operands("topic")[0]);} else {- exports.narrow_title = filter.operands("stream")[0];+ exports.set_narrow_title(filter.operands("stream")[0]);}} else if (filter.has_operator("is")) {- let title = filter.operands("is")[0];- title = title.charAt(0).toUpperCase() + title.slice(1) + " messages";- exports.narrow_title = title;+ const title = filter.operands("is")[0];+ exports.set_narrow_title(title.charAt(0).toUpperCase() + title.slice(1) + " messages");} else if (filter.has_operator("pm-with") || filter.has_operator("group-pm-with")) {const emails = filter.public_operators()[0].operand;const user_ids = people.emails_strings_to_user_ids_string(emails);if (user_ids !== undefined) {const names = people.get_recipients(user_ids);if (filter.has_operator("pm-with")) {- exports.narrow_title = names;+ exports.set_narrow_title(names);} else {- exports.narrow_title = names + " and others";+ exports.set_narrow_title(names + " and others");}} else {if (emails.includes(",")) {- exports.narrow_title = "Invalid users";+ exports.set_narrow_title("Invalid users");} else {- exports.narrow_title = "Invalid user";+ exports.set_narrow_title("Invalid user");}}}- notifications.redraw_title();}-exports.narrow_title = "home";exports.activate = function (raw_operators, opts) {/* Main entrypoint for switching to a new view / message list.Note that for historical reasons related to the currentdiff --git a/static/js/recent_topics.js b/static/js/recent_topics.jsindex b4b7d9e0a7c..73e15a7dff6 100644--- a/static/js/recent_topics.js+++ b/static/js/recent_topics.js@@ -12,7 +12,6 @@ import * as message_view_header from "./message_view_header";import * as muting from "./muting";import * as narrow_state from "./narrow_state";import * as navigate from "./navigate";-import * as notifications from "./notifications";import * as panels from "./panels";import * as people from "./people";import * as recent_senders from "./recent_senders";@@ -496,9 +495,8 @@ export function show() {// with no compose box.compose_actions.cancel();- narrow.narrow_title = "Recent topics";- narrow_state.set_current_filter(undefined);- notifications.redraw_title();+ narrow_state.reset_current_filter();+ narrow.set_narrow_title("Recent topics");message_view_header.render_title_area();complete_rerender();