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.
This commit is contained in:
akshatdalton 2021-04-30 06:59:55 +00:00 committed by Tim Abbott
parent 51e40dd668
commit 91afcda484

View File

@ -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);
}
}