@@ -12,14 +12,14 @@ import { useStream } from '@/stream.js';
12
12
import * as sound from '@/scripts/sound.js' ;
13
13
import { $i , signout , updateAccount } from '@/account.js' ;
14
14
import { ColdDeviceStorage , defaultStore } from '@/store.js' ;
15
- import { makeHotkey } from '@/scripts/hotkey.js' ;
16
15
import { reactionPicker } from '@/scripts/reaction-picker.js' ;
17
16
import { miLocalStorage } from '@/local-storage.js' ;
18
17
import { claimAchievement , claimedAchievements } from '@/scripts/achievements.js' ;
19
18
import { initializeSw } from '@/scripts/initialize-sw.js' ;
20
19
import { deckStore } from '@/ui/deck/deck-store.js' ;
21
20
import { emojiPicker } from '@/scripts/emoji-picker.js' ;
22
21
import { mainRouter } from '@/router/main.js' ;
22
+ import { type Keymap , makeHotkey } from '@/scripts/tms/hotkey.js' ;
23
23
24
24
export async function mainBoot ( ) {
25
25
const { isClientUpdated } = await common ( ( ) => createApp (
@@ -66,14 +66,6 @@ export async function mainBoot() {
66
66
} ) ;
67
67
}
68
68
69
- const hotkeys = {
70
- 'd' : ( ) : void => {
71
- defaultStore . set ( 'darkMode' , ! defaultStore . state . darkMode ) ;
72
- } ,
73
- 's' : ( ) : void => {
74
- mainRouter . push ( '/search' ) ;
75
- } ,
76
- } ;
77
69
try {
78
70
if ( defaultStore . state . enableSeasonalScreenEffect ) {
79
71
const month = new Date ( ) . getMonth ( ) + 1 ;
@@ -102,9 +94,6 @@ export async function mainBoot() {
102
94
}
103
95
104
96
if ( $i ) {
105
- // only add post shortcuts if logged in
106
- hotkeys [ 'p|n' ] = post ;
107
-
108
97
defaultStore . loaded . then ( ( ) => {
109
98
if ( defaultStore . state . accountSetupWizard !== - 1 ) {
110
99
popup ( defineAsyncComponent ( ( ) => import ( '@/components/MkUserSetupDialog.vue' ) ) , { } , { } , 'closed' ) ;
@@ -308,7 +297,19 @@ export async function mainBoot() {
308
297
}
309
298
310
299
// shortcut
311
- document . addEventListener ( 'keydown' , makeHotkey ( hotkeys ) , { passive : false } ) ;
300
+ const keymap = {
301
+ 'p|n' : ( ) => {
302
+ if ( $i == null ) return ;
303
+ post ( ) ;
304
+ } ,
305
+ 'd' : ( ) => {
306
+ defaultStore . set ( 'darkMode' , ! defaultStore . state . darkMode ) ;
307
+ } ,
308
+ 's' : ( ) => {
309
+ mainRouter . push ( '/search' ) ;
310
+ } ,
311
+ } as const satisfies Keymap ;
312
+ document . addEventListener ( 'keydown' , makeHotkey ( keymap ) , { passive : false } ) ;
312
313
313
314
initializeSw ( ) ;
314
315
}
0 commit comments