enh: temporary chat shortcut

This commit is contained in:
Timothy Jaeryang Baek 2024-11-30 18:07:49 -08:00
parent c192475528
commit 19663e539a

View File

@ -97,7 +97,7 @@
banners.set(await getBanners(localStorage.token)); banners.set(await getBanners(localStorage.token));
tools.set(await getTools(localStorage.token)); tools.set(await getTools(localStorage.token));
document.addEventListener('keydown', function (event) { document.addEventListener('keydown', async function (event) {
const isCtrlPressed = event.ctrlKey || event.metaKey; // metaKey is for Cmd key on Mac const isCtrlPressed = event.ctrlKey || event.metaKey; // metaKey is for Cmd key on Mac
// Check if the Shift key is pressed // Check if the Shift key is pressed
const isShiftPressed = event.shiftKey; const isShiftPressed = event.shiftKey;
@ -164,6 +164,18 @@
console.log('showShortcuts'); console.log('showShortcuts');
document.getElementById('show-shortcuts-button')?.click(); document.getElementById('show-shortcuts-button')?.click();
} }
// Check if Ctrl + Shift + ' is pressed
if (isCtrlPressed && isShiftPressed && event.key.toLowerCase() === `'`) {
event.preventDefault();
console.log('temporaryChat');
temporaryChatEnabled.set(!$temporaryChatEnabled);
await goto('/');
const newChatButton = document.getElementById('new-chat-button');
setTimeout(() => {
newChatButton?.click();
}, 0);
}
}); });
if ($user.role === 'admin' && ($settings?.showChangelog ?? true)) { if ($user.role === 'admin' && ($settings?.showChangelog ?? true)) {