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.

keyboard_ui: Add a new keyboard shortcut '='.

SameepAher079eb6a4da38
diff --git a/web/src/hotkey.js b/web/src/hotkey.js
index 40eda884642..e2c18065184 100644
--- a/web/src/hotkey.js
+++ b/web/src/hotkey.js
@@ -123,6 +123,7 @@ const keydown_either_mappings = {
const keypress_mappings = {
42: {name: "star_deprecated", message_view_only: true}, // '*'
43: {name: "thumbs_up_emoji", message_view_only: true}, // '+'
+ 61: {name: "upvote_first_emoji", message_view_only: true}, // '='
45: {name: "toggle_message_collapse", message_view_only: true}, // '-'
47: {name: "search", message_view_only: false}, // '/'
58: {name: "toggle_reactions_popover", message_view_only: true}, // ':'
@@ -967,6 +968,23 @@ export function process_hotkey(e, hotkey) {
reactions.toggle_emoji_reaction(msg.id, canonical_name);
return true;
}
+ case "upvote_first_emoji": {
+ // '=': If the current message has at least one emoji
+ // reaction, toggle out vote on the first one.
+ const message_reactions = reactions.get_message_reactions(msg);
+ if (message_reactions.length === 0) {
+ return true;
+ }
+
+ const first_reaction = message_reactions[0];
+ if (!first_reaction) {
+ // If the message has no emoji reactions, do nothing.
+ return true;
+ }
+
+ reactions.toggle_emoji_reaction(msg.id, first_reaction.emoji_name);
+ return true;
+ }
case "toggle_topic_mute":
muted_topics_ui.toggle_topic_mute(msg);
return true;
diff --git a/web/tests/hotkey.test.js b/web/tests/hotkey.test.js
index f694bffd826..b1545e31774 100644
--- a/web/tests/hotkey.test.js
+++ b/web/tests/hotkey.test.js
@@ -358,6 +358,9 @@ run_test("misc", ({override}) => {
assert_mapping("@", compose_actions, "reply_with_mention");
assert_mapping("+", reactions, "toggle_emoji_reaction");
+ // Without an existing emoji reaction, this next one will only
+ // call get_message_reactions, so we verify just that.
+ assert_mapping("=", reactions, "get_message_reactions");
assert_mapping("-", condense, "toggle_collapse");
assert_mapping("r", compose_actions, "respond_to_message");
assert_mapping("R", compose_actions, "respond_to_message", true);