From cce8f37ada023540a7ec016558eee634dc305b13 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Tue, 31 Dec 2024 02:58:15 -0800 Subject: [PATCH] refac --- src/lib/components/channel/Thread.svelte | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/lib/components/channel/Thread.svelte b/src/lib/components/channel/Thread.svelte index 1b4a811d0..0d31315b9 100644 --- a/src/lib/components/channel/Thread.svelte +++ b/src/lib/components/channel/Thread.svelte @@ -8,7 +8,7 @@ import XMark from '$lib/components/icons/XMark.svelte'; import MessageInput from './MessageInput.svelte'; import Messages from './Messages.svelte'; - import { onMount, tick } from 'svelte'; + import { onDestroy, onMount, tick } from 'svelte'; import { toast } from 'svelte-sonner'; export let threadId = null; @@ -54,6 +54,7 @@ }; const channelEventHandler = async (event) => { + console.log(event); if (event.channel_id === channel.id) { const type = event?.data?.type ?? null; const data = event?.data?.data ?? null; @@ -148,6 +149,10 @@ onMount(() => { $socket?.on('channel-events', channelEventHandler); }); + + onDestroy(() => { + $socket?.off('channel-events', channelEventHandler); + }); {#if channel}