Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
user_topics: Rerender unmuted topics in Recent conversations.
Tim Abbottdee3d7a172be
diff --git a/web/src/muted_topics_ui.js b/web/src/muted_topics_ui.jsindex 4e79351cf0b..17df67e4613 100644--- a/web/src/muted_topics_ui.js+++ b/web/src/muted_topics_ui.js@@ -1,5 +1,3 @@-import _ from "lodash";-import * as message_lists from "./message_lists";import * as overlays from "./overlays";import * as popover_menus from "./popover_menus";@@ -10,8 +8,13 @@ import * as sub_store from "./sub_store";import * as unread_ui from "./unread_ui";import * as user_topics from "./user_topics";-export function rerender_for_muted_topic(old_muted_topics) {+export function handle_topic_updates(user_topic_event) {+ // Update the UI after changes in topic visibility policies.+ user_topics.set_user_topic(user_topic_event);+ popover_menus.get_topic_menu_popover()?.hide();+stream_list.update_streams_sidebar();+ unread_ui.update_unread_counts();message_lists.current.update_muting_and_rerender();if (message_lists.current !== message_lists.home) {message_lists.home.update_muting_and_rerender();@@ -19,28 +22,10 @@ export function rerender_for_muted_topic(old_muted_topics) {if (overlays.settings_open() && settings_muted_topics.loaded) {settings_muted_topics.populate_list();}-- // We only update those topics which could have been affected, because- // we want to avoid doing a complete rerender of the recent topics view,- // because that can be expensive.- const current_muted_topics = user_topics.get_user_topics_for_visibility_policy(- user_topics.all_visibility_policies.MUTED,- );- const maybe_affected_topics = _.unionWith(old_muted_topics, current_muted_topics, _.isEqual);-- for (const topic_data of maybe_affected_topics) {- recent_topics_ui.update_topic_is_muted(topic_data.stream_id, topic_data.topic);- }-}--export function handle_topic_updates(user_topic) {- const old_muted_topics = user_topics.get_user_topics_for_visibility_policy(- user_topics.all_visibility_policies.MUTED,+ recent_topics_ui.update_topic_visibility_policy(+ user_topic_event.stream_id,+ user_topic_event.topic_name,);- user_topics.set_user_topic(user_topic);- popover_menus.get_topic_menu_popover()?.hide();- unread_ui.update_unread_counts();- rerender_for_muted_topic(old_muted_topics);}export function toggle_topic_visibility_policy(message) {diff --git a/web/src/recent_topics_ui.js b/web/src/recent_topics_ui.jsindex 074978a4c67..3154d324a31 100644--- a/web/src/recent_topics_ui.js+++ b/web/src/recent_topics_ui.js@@ -618,7 +618,7 @@ export function inplace_rerender(topic_key) {return true;}-export function update_topic_is_muted(stream_id, topic) {+export function update_topic_visibility_policy(stream_id, topic) {const key = get_topic_key(stream_id, topic);if (!topics.has(key)) {// we receive mute request for a topic we arediff --git a/web/tests/recent_topics.test.js b/web/tests/recent_topics.test.jsindex 0d1d6087ed3..9f328181362 100644--- a/web/tests/recent_topics.test.js+++ b/web/tests/recent_topics.test.js@@ -919,13 +919,13 @@ test("basic assertions", ({mock_template, override_rewire}) => {"1:topic-7,1:topic-3,4:topic-10,1:topic-6,1:topic-5,1:topic-4,1:topic-2,1:topic-1,6,7,8",);- // update_topic_is_muted now relies on external libraries completely+ // update_topic_visibility_policy now relies on external libraries completely// so we don't need to check anythere here.generate_topic_data([[1, topic1, 0, false]]);$(".home-page-input").trigger("focus");- assert.equal(rt.update_topic_is_muted(stream1, topic1), true);+ assert.equal(rt.update_topic_visibility_policy(stream1, topic1), true);// a topic gets muted which we are not tracking- assert.equal(rt.update_topic_is_muted(stream1, "topic-10"), false);+ assert.equal(rt.update_topic_visibility_policy(stream1, "topic-10"), false);});test("test_reify_local_echo_message", ({mock_template}) => {