Prechádzať zdrojové kódy

enh: temporary-chat url search param

Timothy J. Baek 8 mesiacov pred
rodič
commit
dc4c6b3b14

+ 4 - 2
src/lib/components/chat/Chat.svelte

@@ -270,9 +270,11 @@
 	//////////////////////////
 
 	const initNewChat = async () => {
-		window.history.replaceState(history.state, '', `/`);
-		await chatId.set('');
+		if ($page.url.pathname.includes('/c/')) {
+			window.history.replaceState(history.state, '', `/`);
+		}
 
+		await chatId.set('');
 		autoScroll = true;
 
 		title = '';

+ 8 - 0
src/lib/components/chat/ModelSelector/Selector.svelte

@@ -533,6 +533,14 @@
 							setTimeout(() => {
 								newChatButton?.click();
 							}, 0);
+
+							// add 'temporary-chat=true' to the URL
+							if ($temporaryChatEnabled) {
+								history.replaceState(null, '', '?temporary-chat=true');
+							} else {
+								history.replaceState(null, '', location.pathname);
+							}
+
 							show = false;
 						}}
 					>

+ 7 - 1
src/routes/(app)/+layout.svelte

@@ -32,7 +32,8 @@
 		config,
 		showCallOverlay,
 		tools,
-		functions
+		functions,
+		temporaryChatEnabled
 	} from '$lib/stores';
 
 	import SettingsModal from '$lib/components/chat/SettingsModal.svelte';
@@ -40,6 +41,7 @@
 	import ChangelogModal from '$lib/components/ChangelogModal.svelte';
 	import AccountPending from '$lib/components/layout/Overlay/AccountPending.svelte';
 	import { getFunctions } from '$lib/apis/functions';
+	import { page } from '$app/stores';
 
 	const i18n = getContext('i18n');
 
@@ -177,6 +179,10 @@
 				showChangelog.set(localStorage.version !== $config.version);
 			}
 
+			if ($page.url.searchParams.get('temporary-chat') === 'true') {
+				temporaryChatEnabled.set(true);
+			}
+
 			await tick();
 		}