Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
stream_list: Avoid rerender on every fetch.
Aman Agrawalf0717428bb22
diff --git a/web/src/message_events.ts b/web/src/message_events.tsindex b99a406862d..4b1d97f81ff 100644--- a/web/src/message_events.ts+++ b/web/src/message_events.ts@@ -400,7 +400,7 @@ export function insert_new_messages(opts: InsertNewMessagesOpts): Message[] {activity.set_received_new_messages(true);message_notifications.received_messages(messages);- stream_list.update_streams_sidebar();+ stream_list.update_streams_sidebar_for_messages(messages);pm_list.update_private_messages();return messages;diff --git a/web/src/message_fetch.ts b/web/src/message_fetch.tsindex 052f55dd1b9..d0330bb9ed0 100644--- a/web/src/message_fetch.ts+++ b/web/src/message_fetch.ts@@ -177,7 +177,7 @@ function process_result(data: MessageFetchResponse, opts: MessageFetchOptions):}direct_message_group_data.process_loaded_messages(messages);- stream_list.update_streams_sidebar();+ stream_list.update_streams_sidebar_for_messages(messages);stream_list.maybe_scroll_narrow_into_view(!first_messages_fetch);if (diff --git a/web/src/stream_list.ts b/web/src/stream_list.tsindex ac3458e6bd7..22361b4da0c 100644--- a/web/src/stream_list.ts+++ b/web/src/stream_list.ts@@ -69,6 +69,26 @@ export function is_zoomed_in(): boolean {return zoomed_in;}+export function update_streams_sidebar_for_messages(messages: Message[]): void {+ const channel_id = topic_list.active_stream_id();+ if (channel_id === undefined) {+ // If no channel's topic list is expanded, skip the full sidebar+ // re-render. Unread count badges update independently via+ // unread_ui hooks.+ return;+ }++ const should_update = messages.some(+ (message) => message.type === "stream" && message.stream_id === channel_id,+ );++ if (!should_update) {+ return;+ }++ update_streams_sidebar();+}+function zoom_in(): void {zoomed_in = true;const stream_id = topic_list.active_stream_id();