Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

inbox_ui: Allow muting topics without using message object.

Aman Agrawal83719cd5be9c
diff --git a/web/src/inbox_ui.ts b/web/src/inbox_ui.ts
index 65dd5f852d4..0909f82d1f6 100644
--- a/web/src/inbox_ui.ts
+++ b/web/src/inbox_ui.ts
@@ -1566,16 +1566,17 @@ export function get_focused_row_message(): {message?: Message | undefined} & (
}
export function toggle_topic_visibility_policy(): boolean {
+ // Since this function is only called from `hotkey`, we don't
+ // need to move the focus as it is already on the correct row.
+
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;
- }
+ if (inbox_message.msg_type === "stream" && inbox_message.topic !== undefined) {
+ user_topics_ui.toggle_topic_visibility_policy({
+ stream_id: inbox_message.stream_id,
+ topic: inbox_message.topic,
+ type: "stream",
+ });
+ return true;
}
return false;
}
diff --git a/web/src/user_topics_ui.ts b/web/src/user_topics_ui.ts
index 4807ea6d310..9c87a163c5f 100644
--- a/web/src/user_topics_ui.ts
+++ b/web/src/user_topics_ui.ts
@@ -123,7 +123,15 @@ export function handle_topic_updates(
}, 0);
}
-export function toggle_topic_visibility_policy(message: Message): void {
+export function toggle_topic_visibility_policy(
+ message:
+ | Message
+ | {
+ type: Message["type"];
+ stream_id: number;
+ topic: string;
+ },
+): void {
if (message.type !== "stream") {
return;
}