浏览代码

fix: share chat modal

Timothy J. Baek 1 年之前
父节点
当前提交
bfd066cc2f
共有 1 个文件被更改,包括 10 次插入6 次删除
  1. 10 6
      src/lib/components/chat/ShareChatModal.svelte

+ 10 - 6
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);
+			}
+		})();
+	}
 </script>
 
 <Modal bind:show size="sm">