Skip to content

Commit 1c3752e

Browse files
committed
refac
1 parent d057711 commit 1c3752e

1 file changed

Lines changed: 4 additions & 10 deletions

File tree

  • cptr/frontend/src/lib/stores

cptr/frontend/src/lib/stores/chat.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { writable, get } from 'svelte/store';
55
import { toast } from 'svelte-sonner';
66
import { fetchJSON } from '$lib/apis';
77
import { socketStore } from '$lib/stores/socket.svelte';
8-
import { activeTab, openChatTab } from '$lib/stores';
8+
import { activeTab } from '$lib/stores';
99

1010
export const chatEnabled = writable<boolean>(false);
1111

@@ -103,15 +103,9 @@ export function bindGlobalChatListener() {
103103
title,
104104
content: body,
105105
onClick: async () => {
106-
// Navigate to workspace page first if not already there
107-
const wsPath = data.workspace;
108-
if (wsPath && window.location.pathname !== '/') {
109-
const { goto } = await import('$app/navigation');
110-
await goto(`/?workspace=${encodeURIComponent(wsPath)}`);
111-
setTimeout(() => openChatTab(chatId), 300);
112-
} else {
113-
openChatTab(chatId);
114-
}
106+
const { goto } = await import('$app/navigation');
107+
const wsParam = data.workspace ? `workspace=${encodeURIComponent(data.workspace)}&` : '';
108+
await goto(`/?${wsParam}chatId=${encodeURIComponent(chatId)}`);
115109
toast.dismiss(toastId);
116110
},
117111
onclose: () => {

0 commit comments

Comments
 (0)