Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
user_topics_ui: Rerender combined feed to make unmuted topics visible.
Aman Agrawal276e547824b4
diff --git a/web/src/server_events_dispatch.js b/web/src/server_events_dispatch.jsindex e69afa046d6..6d2942be571 100644--- a/web/src/server_events_dispatch.js+++ b/web/src/server_events_dispatch.js@@ -28,6 +28,7 @@ import * as message_edit from "./message_edit.ts";import * as message_events from "./message_events.js";import * as message_lists from "./message_lists.ts";import * as message_live_update from "./message_live_update.ts";+import * as message_view from "./message_view.ts";import * as message_view_header from "./message_view_header.ts";import * as muted_users_ui from "./muted_users_ui.ts";import * as narrow_state from "./narrow_state.ts";@@ -1028,6 +1029,7 @@ export function dispatch_normal_event(event) {user_topics_ui.handle_topic_updates(event,message_events.update_current_view_for_topic_visibility(),+ message_view.rerender_combined_feed,);// Discard cached message lists if `event` topic was / is followed.if (diff --git a/web/src/user_topics_ui.ts b/web/src/user_topics_ui.tsindex 7dfc68528ea..951c33aa281 100644--- a/web/src/user_topics_ui.ts+++ b/web/src/user_topics_ui.ts@@ -2,6 +2,7 @@ import $ from "jquery";import assert from "minimalistic-assert";import * as inbox_util from "./inbox_util.ts";+import type {MessageList} from "./message_list.ts";import * as message_lists from "./message_lists.ts";import type {Message} from "./message_store.ts";import * as narrow_state from "./narrow_state.ts";@@ -36,7 +37,12 @@ function should_add_topic_update_delay(visibility_policy: number): boolean {export function handle_topic_updates(user_topic_event: ServerUserTopic,refreshed_current_narrow = false,+ rerender_combined_feed_callback?: (combined_feed_msg_list: MessageList) => void,): void {+ const was_topic_visible_in_home = user_topics.is_topic_visible_in_home(+ user_topic_event.stream_id,+ user_topic_event.topic_name,+ );// Update the UI after changes in topic visibility policies.user_topics.set_user_topic(user_topic_event);@@ -50,7 +56,23 @@ export function handle_topic_updates();if (!refreshed_current_narrow) {- message_lists.current?.update_muting_and_rerender();+ if (message_lists.current?.data.filter.is_in_home()) {+ const is_topic_visible_in_home = user_topics.is_topic_visible_in_home(+ user_topic_event.stream_id,+ user_topic_event.topic_name,+ );+ if (+ rerender_combined_feed_callback &&+ !was_topic_visible_in_home &&+ is_topic_visible_in_home+ ) {+ rerender_combined_feed_callback(message_lists.current);+ } else {+ message_lists.current.update_muting_and_rerender();+ }+ } else {+ message_lists.current?.update_muting_and_rerender();+ }}},should_add_topic_update_delay(user_topic_event.visibility_policy) ? 500 : 0,@@ -83,7 +105,19 @@ export function handle_topic_updates(// Defer updates for any background-rendered messages lists until the visible one has been updated.for (const list of message_lists.all_rendered_message_lists()) {if (message_lists.current !== list) {- list.update_muting_and_rerender();+ if (list.data.filter.is_in_home()) {+ const is_topic_visible_in_home = user_topics.is_topic_visible_in_home(+ user_topic_event.stream_id,+ user_topic_event.topic_name,+ );+ if (!was_topic_visible_in_home && is_topic_visible_in_home) {+ message_lists.delete_message_list(list);+ } else {+ list.update_muting_and_rerender();+ }+ } else {+ list.update_muting_and_rerender();+ }}}}, 0);