From 91afcda484f3cf7272168dfd11140a8237884bfd Mon Sep 17 00:00:00 2001 From: akshatdalton Date: Fri, 30 Apr 2021 06:59:55 +0000 Subject: [PATCH] topic muting: Show feedback widget only if hotkey (`M`) is used. We are restricting the feedback widget (confirmation pop-up) to be visible to the users if they have muted the topic using the hotkey: `M`, because if the users have muted the topic in some other way then it is known to them about their activity. In fact, the confirmation pop-up was intrusive to some users (see #2367). While using the hotkey they can unknowingly mute the topic. Hence, in such a case, it is necessary to acknowledge the users about their action. --- static/js/muting_ui.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/static/js/muting_ui.js b/static/js/muting_ui.js index f6d6ab3c93..9c5cbe4f3d 100644 --- a/static/js/muting_ui.js +++ b/static/js/muting_ui.js @@ -52,7 +52,7 @@ export function handle_topic_updates(muted_topics) { rerender_for_muted_topic(old_muted_topics); } -export function mute_topic(stream_id, topic) { +export function mute_topic(stream_id, topic, from_hotkey) { const stream_name = stream_data.maybe_get_stream_name(stream_id); const data = { stream_id, @@ -65,6 +65,17 @@ export function mute_topic(stream_id, topic) { idempotent: true, data, success() { + if (!from_hotkey) { + return; + } + + // The following feedback_widget notice helps avoid + // confusion when a user who is not familiar with Zulip's + // keyboard UI hits "M" in the wrong context and has a + // bunch of messages suddenly disappear. This notice is + // only useful when muting from the keyboard, since you + // know what you did if you triggered muting with the + // mouse. feedback_widget.show({ populate(container) { const rendered_html = render_topic_muted(); @@ -108,7 +119,7 @@ export function toggle_topic_mute(message) { if (muting.is_topic_muted(stream_id, topic)) { unmute_topic(stream_id, topic); } else if (message.type === "stream") { - mute_topic(stream_id, topic); + mute_topic(stream_id, topic, true); } }