From bfd066cc2f573021720d39d520adad7b1c1a52a8 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Wed, 3 Apr 2024 19:45:08 -0700 Subject: [PATCH] fix: share chat modal --- src/lib/components/chat/ShareChatModal.svelte | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/lib/components/chat/ShareChatModal.svelte b/src/lib/components/chat/ShareChatModal.svelte index 30ef72e7a..4fa98947d 100644 --- a/src/lib/components/chat/ShareChatModal.svelte +++ b/src/lib/components/chat/ShareChatModal.svelte @@ -54,12 +54,16 @@ export let show = false; - onMount(async () => { - chatId.subscribe(async (value) => { - chat = await getChatById(localStorage.token, value); - console.log(chat); - }); - }); + $: if (show) { + (async () => { + if ($chatId) { + chat = await getChatById(localStorage.token, $chatId); + } else { + chat = null; + console.log(chat); + } + })(); + }