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.

hotkey: Add `y` hotkey support for inbox and recent view.

Aman Agrawal35c0de27fef7
diff --git a/web/src/hotkey.js b/web/src/hotkey.js
index a4b5ff0c0f7..ec0e5ef9bbd 100644
--- a/web/src/hotkey.js
+++ b/web/src/hotkey.js
@@ -56,7 +56,6 @@ import * as sidebar_ui from "./sidebar_ui.ts";
import * as spectators from "./spectators.ts";
import * as starred_messages_ui from "./starred_messages_ui.ts";
import {realm} from "./state_data.ts";
-import * as stream_data from "./stream_data.ts";
import * as stream_list from "./stream_list.ts";
import * as stream_popover from "./stream_popover.ts";
import * as stream_settings_ui from "./stream_settings_ui.ts";
@@ -1101,6 +1100,7 @@ export function process_hotkey(e, hotkey) {
}
// Shortcuts that don't require a message
+ let list_of_channel_topics_channel_id;
switch (event_name) {
case "narrow_private":
message_view.show(
@@ -1184,25 +1184,39 @@ export function process_hotkey(e, hotkey) {
}
return false;
case "list_of_channel_topics":
+ if (recent_view_ui.is_in_focus()) {
+ const msg = recent_view_ui.get_focused_row_message();
+ if (msg !== undefined && msg.type === "stream") {
+ list_of_channel_topics_channel_id = msg.stream_id;
+ }
+ }
+ if (inbox_ui.is_in_focus()) {
+ const msg = inbox_ui.get_focused_row_message();
+ if (msg !== undefined && msg.msg_type === "stream") {
+ list_of_channel_topics_channel_id = msg.stream_id;
+ }
+ }
if (message_lists.current !== undefined) {
- let channel_id;
const selected_message = message_lists.current.selected_message();
if (selected_message === undefined) {
const only_valid_id = true;
- channel_id = narrow_state.stream_id(narrow_state.filter(), only_valid_id);
+ list_of_channel_topics_channel_id = narrow_state.stream_id(
+ narrow_state.filter(),
+ only_valid_id,
+ );
} else if (selected_message.type === "stream") {
- channel_id = stream_data.get_stream_id(selected_message.stream);
- }
-
- if (channel_id === undefined) {
- return false;
+ list_of_channel_topics_channel_id = selected_message.stream_id;
}
+ }
- const channel_topic_list_url = hash_util.by_channel_topic_list_url(channel_id);
- browser_history.go_to_location(channel_topic_list_url);
- return true;
+ if (list_of_channel_topics_channel_id === undefined) {
+ return false;
}
- return false;
+
+ browser_history.go_to_location(
+ hash_util.by_channel_topic_list_url(list_of_channel_topics_channel_id),
+ );
+ return true;
}
// Shortcuts that are useful with an empty message feed, like opening compose.
diff --git a/web/src/inbox_ui.ts b/web/src/inbox_ui.ts
index 9c31e60ed03..d1ffbd967ca 100644
--- a/web/src/inbox_ui.ts
+++ b/web/src/inbox_ui.ts
@@ -1422,6 +1422,10 @@ export function get_focused_row_message(): {message?: Message | undefined} & (
}
const stream_id = Number($focused_row.attr("data-stream-id"));
+ if (Number.isNaN(stream_id)) {
+ // This is a channel folder header.
+ return {};
+ }
compose_state.set_compose_recipient_id(stream_id);
return {message: undefined, msg_type: "stream", stream_id};
}