Skip to content

Commit

Permalink
compose: Fix Cmd + Return to send messages in preview mode on Mac.
Browse files Browse the repository at this point in the history
Previously, Cmd + Return did not send messages in preview mode when
configured by the user.

This commit fixes the logic to allow sending messages in preview
mode with Cmd + Return as per user configuration.
  • Loading branch information
Aditya8840 committed Jan 9, 2025
1 parent f1dd8d8 commit 0b03dfb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions web/src/compose.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,10 @@ export function rewire_send_message(value) {
send_message = value;
}

export function handle_enter_key_with_preview_open(ctrl_pressed = false) {
export function handle_enter_key_with_preview_open(ctrl_or_cmd_pressed = false) {
if (
(user_settings.enter_sends && !ctrl_pressed) ||
(!user_settings.enter_sends && ctrl_pressed)
(user_settings.enter_sends && !ctrl_or_cmd_pressed) ||
(!user_settings.enter_sends && ctrl_or_cmd_pressed)
) {
// If this enter should send, we attempt to send the message.
finish();
Expand Down
12 changes: 6 additions & 6 deletions web/src/hotkey.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ const keydown_unshift_mappings = {

const keydown_ctrl_mappings = {
219: {name: "escape", message_view_only: false}, // '['
13: {name: "ctrl_enter", message_view_only: true}, // enter
};

const keydown_cmd_or_ctrl_mappings = {
13: {name: "action_with_enter", message_view_only: true}, // 'Enter'
67: {name: "copy_with_c", message_view_only: false}, // 'C'
75: {name: "search_with_k", message_view_only: false}, // 'K'
83: {name: "star_message", message_view_only: true}, // 'S'
Expand Down Expand Up @@ -580,10 +580,10 @@ export function process_enter_key(e) {
return true;
}

export function process_ctrl_enter_key() {
export function process_cmd_or_ctrl_enter_key() {
if ($("#preview_message_area").is(":visible")) {
const ctrl_pressed = true;
compose.handle_enter_key_with_preview_open(ctrl_pressed);
const ctrl_or_cmd_pressed = true;
compose.handle_enter_key_with_preview_open(ctrl_or_cmd_pressed);
return true;
}

Expand Down Expand Up @@ -710,8 +710,8 @@ export function process_hotkey(e, hotkey) {
return process_escape_key(e);
case "enter":
return process_enter_key(e);
case "ctrl_enter":
return process_ctrl_enter_key(e);
case "action_with_enter":
return process_cmd_or_ctrl_enter_key(e);
case "tab":
return process_tab_key();
case "shift_tab":
Expand Down

0 comments on commit 0b03dfb

Please sign in to comment.