diff --git a/frontend/apps/main/src/features/command/CommandBox.vue b/frontend/apps/main/src/features/command/CommandBox.vue index edda8ea9..75df8ed4 100644 --- a/frontend/apps/main/src/features/command/CommandBox.vue +++ b/frontend/apps/main/src/features/command/CommandBox.vue @@ -289,17 +289,38 @@ const visibleMacros = computed(() => { return matched }) -const { Meta_K, Ctrl_K } = useMagicKeys({ - passive: false, - onEventFired(e) { - if (e.key === 'k' && (e.metaKey || e.ctrlKey)) { +function preventDefaultOnHotkey(key) { + return (e) => { + if (e.key === key && (e.metaKey || e.ctrlKey)) { e.preventDefault() } } +} + +const { Meta_K, Ctrl_K } = useMagicKeys({ + passive: false, + onEventFired: preventDefaultOnHotkey('k') }) watch([Meta_K, Ctrl_K], ([mac, win]) => { - if (mac || win) toggleOpen() + if (mac || win) { + if (nestedCommand.value !== 'apply-macro-to-new-conversation') setNestedCommand(null) + toggleOpen() + } +}) + +const { Meta_M, Ctrl_M } = useMagicKeys({ + passive: false, + onEventFired: preventDefaultOnHotkey('m') +}) + +watch([Meta_M, Ctrl_M], ([mac, win]) => { + if (mac || win) { + if (nestedCommand.value !== 'apply-macro-to-new-conversation') { + setNestedCommand('apply-macro-to-existing-conversation') + } + toggleOpen() + } }) const highlightedMacro = ref(null) @@ -338,9 +359,6 @@ const otherActions = computed( ) function toggleOpen() { - if (nestedCommand.value != 'apply-macro-to-new-conversation' && !open.value) { - nestedCommand.value = null - } open.value = !open.value } diff --git a/frontend/apps/main/src/features/conversation/CreateConversation.vue b/frontend/apps/main/src/features/conversation/CreateConversation.vue index 50c9a752..2b3c4544 100644 --- a/frontend/apps/main/src/features/conversation/CreateConversation.vue +++ b/frontend/apps/main/src/features/conversation/CreateConversation.vue @@ -321,6 +321,7 @@ const emailQuery = ref('') const conversationStore = useConversationStore() const macroStore = useMacroStore() let timeoutId = null +let previousMacroView = '' const insertContent = ref('') const selectedContact = ref(null) const emailInputRef = ref(null) @@ -367,6 +368,7 @@ onUnmounted(() => { clearTimeout(timeoutId) clearMediaFiles() conversationStore.resetMacro(MACRO_CONTEXT.NEW_CONVERSATION) + macroStore.setCurrentView(previousMacroView) emitter.emit(EMITTER_EVENTS.SET_NESTED_COMMAND, { command: null, open: false @@ -374,6 +376,7 @@ onUnmounted(() => { }) onMounted(() => { + previousMacroView = macroStore.currentView macroStore.setCurrentView('starting_conversation') emitter.emit(EMITTER_EVENTS.SET_NESTED_COMMAND, { command: 'apply-macro-to-new-conversation', diff --git a/frontend/apps/main/src/stores/macro.js b/frontend/apps/main/src/stores/macro.js index d1161a1f..39a6e1dc 100644 --- a/frontend/apps/main/src/stores/macro.js +++ b/frontend/apps/main/src/stores/macro.js @@ -81,6 +81,7 @@ export const useMacroStore = defineStore('macroStore', () => { return { macroList, macroOptions, + currentView, loadMacros, setCurrentView }