Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
stream_muting: Fix stream msgs not displayed when stream in unmuted.
Aman Agrawaldcdd54fcea0f
diff --git a/web/src/browser_history.ts b/web/src/browser_history.tsindex f169ad65b1e..2fcc73aeed7 100644--- a/web/src/browser_history.ts+++ b/web/src/browser_history.ts@@ -168,6 +168,11 @@ export const state_data_schema = z.object({type StateData = z.infer<typeof state_data_schema>;+export function current_scroll_offset(): number | undefined {+ const current_state = state_data_schema.nullable().parse(window.history.state);+ return current_state?.narrow_offset;+}+export function update_current_history_state_data(new_data: StateData): void {const current_state = state_data_schema.nullable().parse(window.history.state);const current_state_data = {diff --git a/web/src/message_view.ts b/web/src/message_view.tsindex 372bfccecea..59818333d75 100644--- a/web/src/message_view.ts+++ b/web/src/message_view.ts@@ -347,7 +347,7 @@ type ShowMessageViewOpts = {trigger?: string;fetched_target_message?: boolean;then_select_id?: number;- then_select_offset?: number;+ then_select_offset?: number | undefined;show_more_topics?: boolean;};@@ -1409,3 +1409,14 @@ function handle_post_view_change(pm_list.handle_narrow_activated(filter);activity_ui.build_user_sidebar();}++export function rerender_combined_feed(combined_feed_msg_list: MessageList): void {+ // Remove cache to avoid repopulating from it.+ message_list_data_cache.remove(combined_feed_msg_list.data.filter);+ show(combined_feed_msg_list.data.filter.terms(), {+ then_select_id: combined_feed_msg_list.selected_id(),+ then_select_offset: browser_history.current_scroll_offset(),+ trigger: "stream / topic visibility policy change",+ force_rerender: true,+ });+}diff --git a/web/src/stream_events.ts b/web/src/stream_events.tsindex 662e76fa3ee..9bf96e5e713 100644--- a/web/src/stream_events.ts+++ b/web/src/stream_events.ts@@ -13,6 +13,7 @@ import * as dialog_widget from "./dialog_widget.ts";import * as hash_util from "./hash_util.ts";import {$t, $t_html} from "./i18n.ts";import * as message_lists from "./message_lists.ts";+import * as message_view from "./message_view.ts";import * as message_view_header from "./message_view_header.ts";import * as narrow_state from "./narrow_state.ts";import * as overlays from "./overlays.ts";@@ -112,7 +113,7 @@ export function update_property<P extends keyof UpdatableStreamProperties>(// modern is_muted events, which we handle below.},is_muted(value) {- stream_muting.update_is_muted(sub, value);+ stream_muting.update_is_muted(sub, value, message_view.rerender_combined_feed);stream_list.refresh_muted_or_unmuted_stream(sub);recent_view_ui.complete_rerender();},diff --git a/web/src/stream_muting.ts b/web/src/stream_muting.tsindex 79c4089431e..33906e6dfd9 100644--- a/web/src/stream_muting.ts+++ b/web/src/stream_muting.ts@@ -1,3 +1,4 @@+import type {MessageList} from "./message_list.ts";import * as message_lists from "./message_lists.ts";import * as settings_notifications from "./settings_notifications.ts";import * as stream_edit from "./stream_edit.ts";@@ -5,7 +6,11 @@ import * as stream_list from "./stream_list.ts";import type {StreamSubscription} from "./sub_store.ts";import * as unread_ui from "./unread_ui.ts";-export function update_is_muted(sub: StreamSubscription, value: boolean): void {+export function update_is_muted(+ sub: StreamSubscription,+ value: boolean,+ rerender_combined_feed_callback: (combined_feed_msg_list: MessageList) => void,+): void {sub.is_muted = value;for (const msg_list of message_lists.all_rendered_message_lists()) {@@ -13,7 +18,11 @@ export function update_is_muted(sub: StreamSubscription, value: boolean): void {// stream muting might need to be live-updated as well, but the// current _all_items design doesn't have a way to support that.if (msg_list.data.filter.is_in_home()) {- msg_list.update_muting_and_rerender();+ if (!value) {+ rerender_combined_feed_callback(msg_list);+ } else {+ msg_list.update_muting_and_rerender();+ }}}