mirror of https://github.com/zulip/zulip.git
hotkeys: Shift + M work in recent conversations and inbox.
Earlier, the Shift + M shortcut only functioned in messages to mute/unmute topics in the messages section. This commit enables the Shift + M shortcut to work in recent conversations and the inbox. It achieves this by utilizing the existing function toggle_topic_visibility_policy in user_topics_ui. The focused row message of the recent_view_ui is passed to mute/unmute the selected topic in the recent_view_ui, and the same process is applied to the inbox_ui but the logic of muting/unmuting the topic is kept in inbox_ui which uses function toggle_topic_visibility_policy in user_topics_ui. The function toggle_topic_visibility_policy is called in both cases based on specific conditions to prevent the shortcut from affecting other parts of the page, thus avoiding errors. Fixes #27741.
This commit is contained in:
parent
454f2f2d95
commit
d145aba3a5
|
@ -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.
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue