From 7b036e54a6d622695ec20b33b06c1db6a7dc3411 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oriol=20G=C3=B3mez?= Date: Fri, 21 Mar 2025 13:28:07 +0100 Subject: [PATCH] fix: move event around --- frontend/src/views/main.ts | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/frontend/src/views/main.ts b/frontend/src/views/main.ts index 1ec821e..e7734ad 100644 --- a/frontend/src/views/main.ts +++ b/frontend/src/views/main.ts @@ -246,23 +246,7 @@ export class MainView extends View { itm.onClick(() => { this.openMessageDialog(message); }) - itm.onKeyDown(async(key: string, alt: boolean | undefined, shift: boolean | undefined, ctrl: boolean | undefined) => { - if ((key.match(/[1-9]/) || key === '0') && alt) { - if (key === '0') key = '10'; - const index = parseInt(key); - const messages = state.currentChannel?.messages; - if (messages && messages.length > 0) { - const msg = messages[messages.length - index]; - if (msg) { - showToast(`${msg.content}; ${this.convertIsoTimeStringToFriendly(msg.createdAt)}`); - } else { - showToast('No message is available in this position'); - } - } else { - showToast('There are no messages in this channel right now') - } - } - + itm.onKeyDown(async (key: string, alt: boolean | undefined, shift: boolean | undefined, ctrl: boolean | undefined) => { if (key === "c") { navigator.clipboard.writeText(message.content.trim()); playSound("copy"); @@ -630,6 +614,24 @@ export class MainView extends View { } private handleHotkey(e: KeyboardEvent) { + let index = 10; + if ((e.key.match(/[1-9]/) || e.key === '0') && e.altKey) { + e.preventDefault(); + if (e.key === '0') index = 10; + index = parseInt(e.key); + const messages = state.currentChannel?.messages; + if (messages && messages.length > 0) { + const msg = messages[messages.length - index]; + if (msg) { + showToast(`${msg.content}; ${this.convertIsoTimeStringToFriendly(msg.createdAt)}`); + } else { + showToast('No message is available in this position'); + } + } else { + showToast('There are no messages in this channel right now') + } + } + if (e.ctrlKey && e.shiftKey) { const action = this.hotkeyMap.get(e.key.toLowerCase()); if (action) {