inbox_ui: Allow muting topics without using message object.

Since muting topics doesn't require a complete message, we can
mute topics with the information we have.
This commit is contained in:
Aman Agrawal
2025-10-09 19:02:10 +05:30
committed by Tim Abbott
parent 97452ea4f8
commit 83719cd5be
2 changed files with 19 additions and 10 deletions

View File

@@ -1566,17 +1566,18 @@ 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);
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;
}

View File

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