summaryrefslogtreecommitdiff
path: root/packages/client/src/init.ts
diff options
context:
space:
mode:
authorAndreas Nedbal <github-bf215181b5140522137b3d4f6b73544a@desu.email>2022-06-25 07:25:22 +0200
committerGitHub <noreply@github.com>2022-06-25 14:25:22 +0900
commit36f09b6cdca904a548b642d0eb6adc05a4095d09 (patch)
tree046a12f62e10abca217e1be0cbd7a1f147ff74f4 /packages/client/src/init.ts
parentfix: always respect instance mutes (#8854) (diff)
downloadsharkey-36f09b6cdca904a548b642d0eb6adc05a4095d09.tar.gz
sharkey-36f09b6cdca904a548b642d0eb6adc05a4095d09.tar.bz2
sharkey-36f09b6cdca904a548b642d0eb6adc05a4095d09.zip
fix(client): only enable hotkeys for logged in users (#8793)
* fix(client): only enable hotkeys for logged in users * fix(client): keep theme and search hotkeys for logged out users
Diffstat (limited to 'packages/client/src/init.ts')
-rw-r--r--packages/client/src/init.ts23
1 files changed, 13 insertions, 10 deletions
diff --git a/packages/client/src/init.ts b/packages/client/src/init.ts
index a11dd2d050..98f69c701f 100644
--- a/packages/client/src/init.ts
+++ b/packages/client/src/init.ts
@@ -287,16 +287,6 @@ fetchInstanceMetaPromise.then(() => {
}
});
-// shortcut
-document.addEventListener('keydown', makeHotkey({
- 'd': () => {
- defaultStore.set('darkMode', !defaultStore.state.darkMode);
- },
- 'p|n': post,
- 's': search,
- //TODO: 'h|/': help
-}));
-
watch(defaultStore.reactiveState.useBlurEffectForModal, v => {
document.documentElement.style.setProperty('--modalBgFilter', v ? 'blur(4px)' : 'none');
}, { immediate: true });
@@ -339,7 +329,17 @@ for (const plugin of ColdDeviceStorage.get('plugins').filter(p => p.active)) {
});
}
+const hotkeys = {
+ 'd': (): void => {
+ defaultStore.set('darkMode', !defaultStore.state.darkMode);
+ },
+ 's': search,
+};
+
if ($i) {
+ // only add post shortcuts if logged in
+ hotkeys['p|n'] = post;
+
if ($i.isDeleted) {
alert({
type: 'warning',
@@ -434,3 +434,6 @@ if ($i) {
signout();
});
}
+
+// shortcut
+document.addEventListener('keydown', makeHotkey(hotkeys));