Browse Source

refac/fix: shortcut modal

Timothy Jaeryang Baek 3 months ago
parent
commit
3e67ce6e8e

+ 3 - 5
src/lib/components/layout/Sidebar/UserMenu.svelte

@@ -9,7 +9,7 @@
 	import { getUsage } from '$lib/apis';
 	import { userSignOut } from '$lib/apis/auths';
 
-	import { showSettings, mobile, showSidebar, user } from '$lib/stores';
+	import { showSettings, mobile, showSidebar, showShortcuts, user } from '$lib/stores';
 
 	import Tooltip from '$lib/components/common/Tooltip.svelte';
 	import ArchiveBox from '$lib/components/icons/ArchiveBox.svelte';
@@ -29,8 +29,6 @@
 	export let help = false;
 	export let className = 'max-w-[240px]';
 
-	let showShortcuts = false;
-
 	const dispatch = createEventDispatcher();
 
 	let usage = null;
@@ -51,7 +49,7 @@
 	}
 </script>
 
-<ShortcutsModal bind:show={showShortcuts} />
+<ShortcutsModal bind:show={$showShortcuts} />
 
 <!-- svelte-ignore a11y-no-static-element-interactions -->
 <DropdownMenu.Root
@@ -173,7 +171,7 @@
 					class="flex gap-2 items-center py-1.5 px-3 text-sm select-none w-full cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 rounded-md transition"
 					id="chat-share-button"
 					on:click={() => {
-						showShortcuts = !showShortcuts;
+						showShortcuts.set(!$showShortcuts);
 						show = false;
 					}}
 				>

+ 1 - 0
src/lib/stores/index.ts

@@ -69,6 +69,7 @@ export const settings: Writable<Settings> = writable({});
 export const showSidebar = writable(false);
 export const showSearch = writable(false);
 export const showSettings = writable(false);
+export const showShortcuts = writable(false);
 export const showArchivedChats = writable(false);
 export const showChangelog = writable(false);
 

+ 3 - 2
src/routes/(app)/+layout.svelte

@@ -34,6 +34,7 @@
 		tags,
 		banners,
 		showSettings,
+		showShortcuts,
 		showChangelog,
 		temporaryChatEnabled,
 		toolServers,
@@ -185,8 +186,8 @@
 				// Check if Ctrl + / is pressed
 				if (isCtrlPressed && event.key === '/') {
 					event.preventDefault();
-					console.log('showShortcuts');
-					document.getElementById('show-shortcuts-button')?.click();
+
+					showShortcuts.set(!$showShortcuts);
 				}
 
 				// Check if Ctrl + Shift + ' is pressed