From 1bc6b13346a33bb88db0d590ccb0e5d5b5e2b559 Mon Sep 17 00:00:00 2001 From: silentoplayz Date: Thu, 11 Jun 2026 14:16:37 -0400 Subject: [PATCH] fix(ui): remove duplicate getChatById fetch in share chat modal --- src/lib/components/chat/ShareChatModal.svelte | 32 ++++++------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/src/lib/components/chat/ShareChatModal.svelte b/src/lib/components/chat/ShareChatModal.svelte index 8d67e47d97..4b6522cc18 100644 --- a/src/lib/components/chat/ShareChatModal.svelte +++ b/src/lib/components/chat/ShareChatModal.svelte @@ -83,30 +83,18 @@ export let show = false; - const isDifferentChat = (_chat) => { - if (!chat) { - return true; - } - if (!_chat) { - return false; - } - return chat.id !== _chat.id || chat.share_id !== _chat.share_id; - }; + let _loadedChatId = null; - $: if (show) { - (async () => { - if (chatId) { - const _chat = await getChatById(localStorage.token, chatId); - if (isDifferentChat(_chat)) { - chat = _chat; - } + $: if (show && chatId) { + if (chatId !== _loadedChatId) { + _loadedChatId = chatId; + (async () => { + chat = await getChatById(localStorage.token, chatId); await loadAccessGrants(); - } else { - chat = null; - accessGrants = []; - console.log(chat); - } - })(); + })(); + } + } else if (!show) { + _loadedChatId = null; }