소스 검색

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">