diff --git a/frontend/src/lib/components/MessageList.svelte b/frontend/src/lib/components/MessageList.svelte index dec099f..199dfd6 100644 --- a/frontend/src/lib/components/MessageList.svelte +++ b/frontend/src/lib/components/MessageList.svelte @@ -179,7 +179,7 @@ return messages.find((m) => holds(m, messageId))?.message_id ?? null; } - function jumpToMessage(messageId: number) { + function jumpToMessage(messageId: number, smooth = true) { const owner = ownerOf(messageId) ?? messageId; const target = container?.querySelector( `[data-message-id="${owner}"]` @@ -188,7 +188,10 @@ toasts.error(t("thread.notFound")); return; } - target.scrollIntoView({ behavior: "smooth", block: "center" }); + target.scrollIntoView({ + behavior: smooth ? "smooth" : "auto", + block: "center", + }); highlightId = owner; if (highlightTimer) { clearTimeout(highlightTimer); @@ -229,7 +232,7 @@ ui.clearJump(); await loadAround(pending.messageId); await tick(); - jumpToMessage(pending.messageId); + jumpToMessage(pending.messageId, false); return; } const page = await listMessages(chatId, { @@ -514,11 +517,12 @@ async function goTo(messageId: number) { try { - if (ownerOf(messageId) === null) { + const loaded = ownerOf(messageId) !== null; + if (!loaded) { await loadAround(messageId); } await tick(); - jumpToMessage(messageId); + jumpToMessage(messageId, loaded); } catch { toasts.error(t("thread.loadFailed")); } diff --git a/frontend/src/routes/app/[chatId]/+page.svelte b/frontend/src/routes/app/[chatId]/+page.svelte index 5e41b36..4e81e5f 100644 --- a/frontend/src/routes/app/[chatId]/+page.svelte +++ b/frontend/src/routes/app/[chatId]/+page.svelte @@ -20,7 +20,7 @@ chats.enrich(chatId); }); - $effect(() => { + $effect.pre(() => { if (linkedMessage === null) { return; }