From 3a9dfc02e6414089de8ed5cbc85eb69f60454013 Mon Sep 17 00:00:00 2001 From: Abhijeet Prasad Bodas Date: Sat, 27 Mar 2021 16:07:31 +0530 Subject: [PATCH] refactor: Rename MessageList.update_muting_and_rerender. This is a prep commit for implementing mute users feature, which renames this function to be more specific. This function cannot be used as-is for user mutes, because for user-muted messages, we always want to rerender the message list, irrespective of what `excludes_muted_users` is. In muting_ui.js, we also remove an unnecessary conditional that is already handled by update_topic_muting_and_rerender itself. --- static/js/message_events.js | 4 ++-- static/js/message_list.js | 9 ++++----- static/js/muting_ui.js | 6 ++---- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/static/js/message_events.js b/static/js/message_events.js index 51d5b70fb4..1e686c1b74 100644 --- a/static/js/message_events.js +++ b/static/js/message_events.js @@ -401,11 +401,11 @@ export function update_messages(events) { // propagated edits to be updated (since the topic edits can have // changed the correct grouping of messages). if (topic_edited || stream_changed) { - message_lists.home.update_muting_and_rerender(); + message_lists.home.update_topic_muting_and_rerender(); // However, we don't need to rerender message_list.narrowed if // we just changed the narrow earlier in this function. if (!changed_narrow && message_lists.current === message_list.narrowed) { - message_list.narrowed.update_muting_and_rerender(); + message_list.narrowed.update_topic_muting_and_rerender(); } } else { // If the content of the message was edited, we do a special animation. diff --git a/static/js/message_list.js b/static/js/message_list.js index 7e41b72239..db9461e53a 100644 --- a/static/js/message_list.js +++ b/static/js/message_list.js @@ -379,12 +379,11 @@ export class MessageList { } } - update_muting_and_rerender() { - if (!this.excludes_muted_topics) { - return; + update_topic_muting_and_rerender() { + if (this.excludes_muted_topics) { + this.data.update_items_for_muting(); + this.rerender(); } - this.data.update_items_for_muting(); - this.rerender(); } all_messages() { diff --git a/static/js/muting_ui.js b/static/js/muting_ui.js index 5ec8934f05..e6038d73e5 100644 --- a/static/js/muting_ui.js +++ b/static/js/muting_ui.js @@ -32,11 +32,9 @@ export function rerender_on_topic_update() { stream_list.update_streams_sidebar(); recent_topics.complete_rerender(); - if (message_lists.current.excludes_muted_topics) { - message_lists.current.update_muting_and_rerender(); - } + message_lists.current.update_topic_muting_and_rerender(); if (message_lists.current !== message_lists.home) { - message_lists.home.update_muting_and_rerender(); + message_lists.home.update_topic_muting_and_rerender(); } if (overlays.settings_open() && settings_muting.loaded) { set_up_muted_topics_ui();