This commit is contained in:
Timothy Jaeryang Baek 2024-12-31 02:30:03 -08:00
parent 85038cef69
commit c8cdc6377b

View File

@ -22,10 +22,16 @@
let typingUsers = []; let typingUsers = [];
let typingUsersTimeout = {}; let typingUsersTimeout = {};
let messagesContainerElement = null;
$: if (threadId) { $: if (threadId) {
initHandler(); initHandler();
} }
const scrollToBottom = () => {
messagesContainerElement.scrollTop = messagesContainerElement.scrollHeight;
};
const initHandler = async () => { const initHandler = async () => {
messages = null; messages = null;
top = false; top = false;
@ -39,6 +45,9 @@
if (messages.length < 50) { if (messages.length < 50) {
top = true; top = true;
} }
await tick();
scrollToBottom();
} else { } else {
goto('/'); goto('/');
} }
@ -152,7 +161,7 @@
</div> </div>
</div> </div>
<div class=" max-h-full w-full overflow-y-auto"> <div class=" max-h-full w-full overflow-y-auto" bind:this={messagesContainerElement}>
<Messages <Messages
id={threadId} id={threadId}
{channel} {channel}