Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
shortcuts: Update `Shift + M` shortcut to work for unmute topics too.
Hardik Dharmani82bf1ba58a6c
diff --git a/web/src/hotkey.js b/web/src/hotkey.jsindex ac2df50562d..22bd7dc0b79 100644--- a/web/src/hotkey.js+++ b/web/src/hotkey.js@@ -136,7 +136,7 @@ const keypress_mappings = {71: {name: "G_end", message_view_only: true}, // 'G'74: {name: "vim_page_down", message_view_only: true}, // 'J'75: {name: "vim_page_up", message_view_only: true}, // 'K'- 77: {name: "toggle_topic_mute", message_view_only: true}, // 'M'+ 77: {name: "toggle_topic_visibility_policy", message_view_only: true}, // 'M'80: {name: "narrow_private", message_view_only: true}, // 'P'82: {name: "respond_to_author", message_view_only: true}, // 'R'83: {name: "narrow_by_topic", message_view_only: true}, // 'S'@@ -991,8 +991,8 @@ export function process_hotkey(e, hotkey) {reactions.toggle_emoji_reaction(msg.id, first_reaction.emoji_name);return true;}- case "toggle_topic_mute":- muted_topics_ui.toggle_topic_mute(msg);+ case "toggle_topic_visibility_policy":+ muted_topics_ui.toggle_topic_visibility_policy(msg);return true;case "toggle_message_collapse":condense.toggle_collapse(msg);diff --git a/web/src/muted_topics_ui.js b/web/src/muted_topics_ui.jsindex e00401cb671..5f6e94e67a3 100644--- a/web/src/muted_topics_ui.js+++ b/web/src/muted_topics_ui.js@@ -6,6 +6,7 @@ import * as popover_menus from "./popover_menus";import * as recent_topics_ui from "./recent_topics_ui";import * as settings_muted_topics from "./settings_muted_topics";import * as stream_list from "./stream_list";+import * as sub_store from "./sub_store";import * as unread_ui from "./unread_ui";import * as user_topics from "./user_topics";@@ -38,23 +39,35 @@ export function handle_topic_updates(user_topic) {rerender_for_muted_topic(old_muted_topics);}-export function toggle_topic_mute(message) {+export function toggle_topic_visibility_policy(message) {const stream_id = message.stream_id;const topic = message.topic;- if (user_topics.is_topic_muted(stream_id, topic)) {+ if (+ user_topics.is_topic_muted(stream_id, topic) ||+ user_topics.is_topic_unmuted(stream_id, topic)+ ) {user_topics.set_user_topic_visibility_policy(stream_id,topic,user_topics.all_visibility_policies.INHERIT,);} else if (message.type === "stream") {- user_topics.set_user_topic_visibility_policy(- stream_id,- topic,- user_topics.all_visibility_policies.MUTED,- true,- );+ if (sub_store.get(stream_id).is_muted) {+ user_topics.set_user_topic_visibility_policy(+ stream_id,+ topic,+ user_topics.all_visibility_policies.UNMUTED,+ true,+ );+ } else {+ user_topics.set_user_topic_visibility_policy(+ stream_id,+ topic,+ user_topics.all_visibility_policies.MUTED,+ true,+ );+ }}}diff --git a/web/src/user_topics.js b/web/src/user_topics.jsindex a950e88f790..2a3931bc3c0 100644--- a/web/src/user_topics.js+++ b/web/src/user_topics.js@@ -100,24 +100,26 @@ export function set_user_topic_visibility_policy(stream_id, topic, visibility_po// only useful when muting from the keyboard, since you// know what you did if you triggered muting with the// mouse.- const stream_name = stream_data.maybe_get_stream_name(stream_id);- feedback_widget.show({- populate($container) {- const rendered_html = render_topic_muted();- $container.html(rendered_html);- $container.find(".stream").text(stream_name);- $container.find(".topic").text(topic);- },- on_undo() {- set_user_topic_visibility_policy(- stream_id,- topic,- all_visibility_policies.INHERIT,- );- },- title_text: $t({defaultMessage: "Topic muted"}),- undo_button_text: $t({defaultMessage: "Undo mute"}),- });+ if (visibility_policy === all_visibility_policies.MUTED) {+ const stream_name = stream_data.maybe_get_stream_name(stream_id);+ feedback_widget.show({+ populate($container) {+ const rendered_html = render_topic_muted();+ $container.html(rendered_html);+ $container.find(".stream").text(stream_name);+ $container.find(".topic").text(topic);+ },+ on_undo() {+ set_user_topic_visibility_policy(+ stream_id,+ topic,+ all_visibility_policies.INHERIT,+ );+ },+ title_text: $t({defaultMessage: "Topic muted"}),+ undo_button_text: $t({defaultMessage: "Undo mute"}),+ });+ }},});}diff --git a/web/tests/hotkey.test.js b/web/tests/hotkey.test.jsindex 74ab3bb718c..11be0485ea6 100644--- a/web/tests/hotkey.test.js+++ b/web/tests/hotkey.test.js@@ -405,7 +405,7 @@ run_test("emoji picker", ({override}) => {run_test("G/M keys", () => {// TODO: moveassert_mapping("G", navigate, "to_end");- assert_mapping("M", muted_topics_ui, "toggle_topic_mute");+ assert_mapping("M", muted_topics_ui, "toggle_topic_visibility_policy");});run_test("n/p keys", () => {