mirror of
https://github.com/Blah-IM/Weblah.git
synced 2025-05-01 00:31:08 +00:00
fix: history follow latest
This commit is contained in:
parent
13bd2e31e7
commit
38c08ec8d9
1 changed files with 8 additions and 2 deletions
|
@ -3,13 +3,19 @@
|
|||
|
||||
import type { Message } from '$lib/types';
|
||||
import ChatMessage from './ChatMessage.svelte';
|
||||
import { tick } from 'svelte';
|
||||
|
||||
export let messages: Message[] = [];
|
||||
export let mySenderId: string;
|
||||
|
||||
let ref: VList<Message>;
|
||||
let ref: VList<Message> | undefined;
|
||||
|
||||
$: ref?.scrollToIndex(messages.length - 1, { align: 'end', smooth: true });
|
||||
async function scrollToIndex(index: number, smooth = true) {
|
||||
await tick();
|
||||
ref?.scrollToIndex(index, { align: 'end', smooth });
|
||||
}
|
||||
|
||||
$: scrollToIndex(messages.length - 1);
|
||||
</script>
|
||||
|
||||
<VList data={messages} let:item={message} class="size-full pt-2" bind:this={ref}>
|
||||
|
|
Loading…
Add table
Reference in a new issue