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 `z` shortcut to zoom to message `near` view.

N-Shar-ma599a32bee91a
diff --git a/help/keyboard-shortcuts.md b/help/keyboard-shortcuts.md
index d3b237ff714..8fc8fd5cd6c 100644
--- a/help/keyboard-shortcuts.md
+++ b/help/keyboard-shortcuts.md
@@ -89,6 +89,8 @@ in the Zulip app to add more to your repertoire as needed.
* **Narrow to all private messages**: <kbd>Shift</kbd> + <kbd>P</kbd>
+* **Zoom to message in conversation context**: <kbd>Z</kbd> — This view does not mark messages as read.
+
* **Cycle between stream narrows**: <kbd>Shift</kbd> + <kbd>A</kbd>
(previous) and <kbd>Shift</kbd> + <kbd>D</kbd> (next)
diff --git a/web/src/hotkey.js b/web/src/hotkey.js
index beda6929e5d..40eda884642 100644
--- a/web/src/hotkey.js
+++ b/web/src/hotkey.js
@@ -162,6 +162,7 @@ const keypress_mappings = {
118: {name: "show_lightbox", message_view_only: true}, // 'v'
119: {name: "query_users", message_view_only: true}, // 'w'
120: {name: "compose_private_message", message_view_only: true}, // 'x'
+ 122: {name: "zoom_to_message_near", message_view_only: true}, // 'z'
};
export function get_keydown_hotkey(e) {
@@ -991,6 +992,32 @@ export function process_hotkey(e, hotkey) {
stream_popover.build_move_topic_to_stream_popover(msg.stream_id, msg.topic, msg);
return true;
}
+ case "zoom_to_message_near": {
+ // The following code is essentially equivalent to
+ // `window.location = hashutil.by_conversation_and_time_url(msg)`
+ // but we use `narrow.activate` to pass in the `trigger` parameter
+ switch (msg.type) {
+ case "private":
+ narrow.activate(
+ [
+ {operator: "pm-with", operand: msg.reply_to},
+ {operator: "near", operand: msg.id},
+ ],
+ {trigger: "hotkey"},
+ );
+ return true;
+ case "stream":
+ narrow.activate(
+ [
+ {operator: "stream", operand: msg.stream},
+ {operator: "topic", operand: msg.topic},
+ {operator: "near", operand: msg.id},
+ ],
+ {trigger: "hotkey"},
+ );
+ return true;
+ }
+ }
}
return false;
diff --git a/web/templates/keyboard_shortcuts.hbs b/web/templates/keyboard_shortcuts.hbs
index b8d3bd8dfe1..3b907d6b4aa 100644
--- a/web/templates/keyboard_shortcuts.hbs
+++ b/web/templates/keyboard_shortcuts.hbs
@@ -175,6 +175,10 @@
<td class="definition">{{t 'Narrow to all private messages' }}</td>
<td><span class="hotkey"><kbd>Shift</kbd> + <kbd>P</kbd></span></td>
</tr>
+ <tr>
+ <td class="definition">{{t 'Zoom to message in conversation context' }}</td>
+ <td><span class="hotkey"><kbd>Z</kbd></span></td>
+ </tr>
<tr>
<td class="definition">{{t 'Narrow to next unread topic' }}</td>
<td><span class="hotkey"><kbd>N</kbd></span></td>