Merge pull request #365 from vanboom/363-macro-hotkey

Resolves #363, implement CTRL+M hotkey to access the macro dialog
This commit is contained in:
Abhinav Raut
2026-06-06 21:08:04 +05:30
committed by GitHub
3 changed files with 30 additions and 8 deletions
@@ -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
}
@@ -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',
+1
View File
@@ -81,6 +81,7 @@ export const useMacroStore = defineStore('macroStore', () => {
return {
macroList,
macroOptions,
currentView,
loadMacros,
setCurrentView
}