diff options
| author | かっこかり <67428053+kakkokari-gtyih@users.noreply.github.com> | 2024-07-09 17:59:15 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-09 17:59:15 +0900 |
| commit | a5407131d4d15edca924e2718902cefd81e49ee2 (patch) | |
| tree | bad6d1e08071e9e14624a4d64fb851f137bb4fee /packages/frontend/src/boot/main-boot.ts | |
| parent | Bump release actions to v2 (develop-stable(master) branches system) (#13941) (diff) | |
| download | misskey-a5407131d4d15edca924e2718902cefd81e49ee2.tar.gz misskey-a5407131d4d15edca924e2718902cefd81e49ee2.tar.bz2 misskey-a5407131d4d15edca924e2718902cefd81e49ee2.zip | |
fix/refactor(frontend): hotkeyの改修 (#14157)
* improve(frontend): hotkeyの改修 (#234)
(cherry picked from commit 678be147f4db709dadf25d007cc2e679e98a370e)
* Change path, add missing script
Co-authored-by: taiy <53635909+taiyme@users.noreply.github.com>
* fix
* fix
* add missing keycodes
* fix
* update changelog
---------
Co-authored-by: taiy <53635909+taiyme@users.noreply.github.com>
Diffstat (limited to 'packages/frontend/src/boot/main-boot.ts')
| -rw-r--r-- | packages/frontend/src/boot/main-boot.ts | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/packages/frontend/src/boot/main-boot.ts b/packages/frontend/src/boot/main-boot.ts index faf230a1a2..d327016317 100644 --- a/packages/frontend/src/boot/main-boot.ts +++ b/packages/frontend/src/boot/main-boot.ts @@ -13,7 +13,6 @@ import * as sound from '@/scripts/sound.js'; import { $i, signout, updateAccount } from '@/account.js'; import { instance } from '@/instance.js'; import { ColdDeviceStorage, defaultStore } from '@/store.js'; -import { makeHotkey } from '@/scripts/hotkey.js'; import { reactionPicker } from '@/scripts/reaction-picker.js'; import { miLocalStorage } from '@/local-storage.js'; import { claimAchievement, claimedAchievements } from '@/scripts/achievements.js'; @@ -21,6 +20,7 @@ import { initializeSw } from '@/scripts/initialize-sw.js'; import { deckStore } from '@/ui/deck/deck-store.js'; import { emojiPicker } from '@/scripts/emoji-picker.js'; import { mainRouter } from '@/router/main.js'; +import { type Keymap, makeHotkey } from '@/scripts/hotkey.js'; export async function mainBoot() { const { isClientUpdated } = await common(() => createApp( @@ -69,14 +69,6 @@ export async function mainBoot() { }); } - const hotkeys = { - 'd': (): void => { - defaultStore.set('darkMode', !defaultStore.state.darkMode); - }, - 's': (): void => { - mainRouter.push('/search'); - }, - }; try { if (defaultStore.state.enableSeasonalScreenEffect) { const month = new Date().getMonth() + 1; @@ -105,9 +97,6 @@ export async function mainBoot() { } if ($i) { - // only add post shortcuts if logged in - hotkeys['p|n'] = post; - defaultStore.loaded.then(() => { if (defaultStore.state.accountSetupWizard !== -1) { const { dispose } = popup(defineAsyncComponent(() => import('@/components/MkUserSetupDialog.vue')), {}, { @@ -334,7 +323,19 @@ export async function mainBoot() { } // shortcut - document.addEventListener('keydown', makeHotkey(hotkeys)); + const keymap = { + 'p|n': () => { + if ($i == null) return; + post(); + }, + 'd': () => { + defaultStore.set('darkMode', !defaultStore.state.darkMode); + }, + 's': () => { + mainRouter.push('/search'); + }, + } as const satisfies Keymap; + document.addEventListener('keydown', makeHotkey(keymap), { passive: false }); initializeSw(); } |