@@ -13,6 +13,8 @@ interface ShortcutConfig {
1313 storageKey : string
1414 defaultKey : string
1515 section : 'global' | 'app'
16+ action ?: string
17+ oldShortcutStorageKey ?: string
1618}
1719
1820export function KeybindsModal ( { onClose } : KeybindsModalProps ) {
@@ -26,13 +28,17 @@ export function KeybindsModal({ onClose }: KeybindsModalProps) {
2628 storageKey : SETTINGS_KEYS . SHORTCUT_TOGGLE ,
2729 defaultKey : `${ defaultMod } +Shift+C` ,
2830 section : 'global' ,
31+ action : 'toggle' ,
32+ oldShortcutStorageKey : 'papercache-shortcut-toggle' ,
2933 } ,
3034 {
3135 key : 'shortcutNewNote' ,
3236 label : 'New Note (Global)' ,
3337 storageKey : SETTINGS_KEYS . SHORTCUT_NEWNOTE ,
3438 defaultKey : `${ defaultMod } +Shift+N` ,
3539 section : 'global' ,
40+ action : 'new-note' ,
41+ oldShortcutStorageKey : 'papercache-shortcut-newnote' ,
3642 } ,
3743 {
3844 key : 'shortcutTasks' ,
@@ -121,15 +127,12 @@ export function KeybindsModal({ onClose }: KeybindsModalProps) {
121127
122128 const handleSave = ( ) => {
123129 for ( const sc of shortcuts ) {
124- if ( sc . section === 'global' ) {
125- const oldShortcutKey =
126- sc . key === 'shortcutToggle' ? 'papercache-shortcut-toggle' : 'papercache-shortcut-newnote'
127- const oldShortcut = localStorage . getItem ( oldShortcutKey ) || sc . defaultKey
128- const action = sc . key === 'shortcutToggle' ? 'toggle' : 'new-note'
130+ if ( sc . section === 'global' && sc . action && sc . oldShortcutStorageKey ) {
131+ const oldShortcut = localStorage . getItem ( sc . oldShortcutStorageKey ) || sc . defaultKey
129132 if ( window . electronAPI . updateGlobalShortcut ) {
130- window . electronAPI . updateGlobalShortcut ( action , oldShortcut , values [ sc . key ] )
133+ window . electronAPI . updateGlobalShortcut ( sc . action , oldShortcut , values [ sc . key ] )
131134 }
132- localStorage . setItem ( oldShortcutKey , values [ sc . key ] )
135+ localStorage . setItem ( sc . oldShortcutStorageKey , values [ sc . key ] )
133136 }
134137 localStorage . setItem ( sc . storageKey , values [ sc . key ] )
135138 }
0 commit comments