diff --git a/web/src/hotkey.js b/web/src/hotkey.js index db0b09fa2e..0148feea4d 100644 --- a/web/src/hotkey.js +++ b/web/src/hotkey.js @@ -971,6 +971,18 @@ export function process_hotkey(e, hotkey) { case "all_messages": browser_history.go_to_location("#all_messages"); return true; + case "toggle_topic_visibility_policy": + if (recent_view_ui.is_in_focus()) { + const recent_msg = recent_view_ui.get_focused_row_message(); + if (recent_msg !== undefined && recent_msg.type === "stream") { + user_topics_ui.toggle_topic_visibility_policy(recent_msg); + return true; + } + return false; + } + if (inbox_ui.is_in_focus()) { + return inbox_ui.toggle_topic_visibility_policy(); + } } // Shortcuts that are useful with an empty message feed, like opening compose. diff --git a/web/src/inbox_ui.js b/web/src/inbox_ui.js index df6e67e6ef..a2f48acc86 100644 --- a/web/src/inbox_ui.js +++ b/web/src/inbox_ui.js @@ -28,6 +28,7 @@ import * as unread from "./unread"; import * as unread_ops from "./unread_ops"; import * as user_status from "./user_status"; import * as user_topics from "./user_topics"; +import * as user_topics_ui from "./user_topics_ui"; import * as util from "./util"; import * as views_util from "./views_util"; @@ -741,6 +742,21 @@ export function get_focused_row_message() { return {message}; } +export function toggle_topic_visibility_policy() { + const inbox_message = get_focused_row_message(); + if (inbox_message.message !== undefined) { + user_topics_ui.toggle_topic_visibility_policy(inbox_message.message); + if (inbox_message.message.type === "stream") { + // means mute/unmute action is taken + const $elt = $(".inbox-header"); // Select the element with class "inbox-header" + const $focusElement = $elt.find(get_focus_class_for_header()).first(); + focus_clicked_list_element($focusElement); + return true; + } + } + return false; +} + function is_row_a_header($row) { return $row.hasClass("inbox-header"); }