zulip/web/src/stream_muting.js
Tim Abbott ae314a3ca9 message_list: Deduplicate stream muting live update code path.
We can dramtically simplify the stream muting live-update code path
for updating home_msg_list by observing the only thing it was doing
intentionally differently from update_muting_and_rerender is replacing
_all_items with a new version computed from from all_messages_data,
and the rest of update_muting_and_rerender can handle the live update
correctly unmodified.

This deduplication means live-update of "Unmute topic" just requires
updating the `in:home` filter logic appropriately, without any special
live update work.
2023-04-21 13:52:02 -07:00

23 lines
913 B
JavaScript

import * as message_lists from "./message_lists";
import * as settings_notifications from "./settings_notifications";
import * as stream_edit from "./stream_edit";
import * as stream_list from "./stream_list";
import * as unread_ui from "./unread_ui";
export function update_is_muted(sub, value) {
sub.is_muted = value;
// TODO: In theory, other message lists whose behavior depends on
// stream muting might need to be live-updated as well, but the
// current _all_items design doesn't have a way to support that.
message_lists.home.update_muting_and_rerender();
// Since muted streams aren't counted in visible unread
// counts, we need to update the rendering of them.
unread_ui.update_unread_counts();
settings_notifications.update_muted_stream_state(sub);
stream_edit.update_muting_rendering(sub);
stream_list.set_in_home_view(sub.stream_id, !sub.is_muted);
}