mirror of
https://github.com/zulip/zulip.git
synced 2025-10-23 04:52:12 +00:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user