From 3f736c9b0674d2f46f14a359acaadcf135293014 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Fri, 27 Apr 2018 08:35:02 -0700 Subject: [PATCH] message_list: Clean up API for rerender_after_muting_changes. This was only called from two places in one function, and we can just check muting_enabled in the caller. This refactor is important, because we might need to update muting after other changes (specifically, message editing to move a topic to be muted/non-muted). --- static/js/message_list.js | 6 +----- static/js/muting_ui.js | 6 ++++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/static/js/message_list.js b/static/js/message_list.js index f2bbd41bcd..53bf8495f2 100644 --- a/static/js/message_list.js +++ b/static/js/message_list.js @@ -564,11 +564,7 @@ exports.MessageList.prototype = { } }, - rerender_after_muting_changes: function MessageList_rerender_after_muting_changes() { - if (!this.muting_enabled) { - return; - } - + update_muting_and_rerender: function MessageList_update_muting_and_rerender() { this._items = this.unmuted_messages(this._all_items); this.rerender(); }, diff --git a/static/js/muting_ui.js b/static/js/muting_ui.js index 7886d2b82a..305f4ecdee 100644 --- a/static/js/muting_ui.js +++ b/static/js/muting_ui.js @@ -15,9 +15,11 @@ exports.rerender = function () { // re-doing a mute or unmute is a pretty recoverable thing. stream_list.update_streams_sidebar(); - current_msg_list.rerender_after_muting_changes(); + if (current_msg_list.muting_enabled) { + current_msg_list.update_muting_and_rerender(); + } if (current_msg_list !== home_msg_list) { - home_msg_list.rerender_after_muting_changes(); + home_msg_list.update_muting_and_rerender(); } };