fix: url param issue

#14901
This commit is contained in:
Timothy Jaeryang Baek 2025-06-11 20:16:53 +04:00
parent 387c2377ba
commit 6076afd5f5
2 changed files with 7 additions and 15 deletions

View File

@ -432,31 +432,20 @@
}
};
let pageSubscribe = null;
onMount(async () => {
loading = true;
console.log('mounted');
window.addEventListener('message', onMessageHandler);
$socket?.on('chat-events', chatEventHandler);
page.subscribe((page) => {
if (page.url.pathname === '/') {
pageSubscribe = page.subscribe(async (p) => {
if (p.url.pathname === '/') {
await tick();
initNewChat();
}
});
if (!$chatId) {
chatIdUnsubscriber = chatId.subscribe(async (value) => {
if (!value) {
await tick(); // Wait for DOM updates
await initNewChat();
}
});
} else {
if ($temporaryChatEnabled) {
await goto('/');
}
}
if (localStorage.getItem(`chat-input${chatIdProp ? `-${chatIdProp}` : ''}`)) {
prompt = '';
files = [];
@ -515,6 +504,7 @@
});
onDestroy(() => {
pageSubscribe();
chatIdUnsubscriber?.();
window.removeEventListener('message', onMessageHandler);
$socket?.off('chat-events', chatEventHandler);

View File

@ -490,6 +490,8 @@
draggable="false"
on:click={async () => {
selectedChatId = null;
await temporaryChatEnabled.set(false);
await goto('/');
const newChatButton = document.getElementById('new-chat-button');
setTimeout(() => {