forked from FoundKeyGang/FoundKey
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
This commit is contained in:
parent
e45624855f
commit
631c3bac58
1 changed files with 13 additions and 10 deletions
|
@ -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 => {
|
watch(defaultStore.reactiveState.useBlurEffectForModal, v => {
|
||||||
document.documentElement.style.setProperty('--modalBgFilter', v ? 'blur(4px)' : 'none');
|
document.documentElement.style.setProperty('--modalBgFilter', v ? 'blur(4px)' : 'none');
|
||||||
}, { immediate: true });
|
}, { 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) {
|
if ($i) {
|
||||||
|
// only add post shortcuts if logged in
|
||||||
|
hotkeys['p|n'] = post;
|
||||||
|
|
||||||
if ($i.isDeleted) {
|
if ($i.isDeleted) {
|
||||||
alert({
|
alert({
|
||||||
type: 'warning',
|
type: 'warning',
|
||||||
|
@ -434,3 +434,6 @@ if ($i) {
|
||||||
signout();
|
signout();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// shortcut
|
||||||
|
document.addEventListener('keydown', makeHotkey(hotkeys));
|
||||||
|
|
Loading…
Reference in a new issue