From c8cdc6377bc7ed408a58c2dfc086d9b7844978ca Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Tue, 31 Dec 2024 02:30:03 -0800 Subject: [PATCH] refac --- src/lib/components/channel/Thread.svelte | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/lib/components/channel/Thread.svelte b/src/lib/components/channel/Thread.svelte index aa26f3ded..fc8638b92 100644 --- a/src/lib/components/channel/Thread.svelte +++ b/src/lib/components/channel/Thread.svelte @@ -22,10 +22,16 @@ let typingUsers = []; let typingUsersTimeout = {}; + let messagesContainerElement = null; + $: if (threadId) { initHandler(); } + const scrollToBottom = () => { + messagesContainerElement.scrollTop = messagesContainerElement.scrollHeight; + }; + const initHandler = async () => { messages = null; top = false; @@ -39,6 +45,9 @@ if (messages.length < 50) { top = true; } + + await tick(); + scrollToBottom(); } else { goto('/'); } @@ -152,7 +161,7 @@ -
+