diff --git a/src/app/components/RoomChat.svelte b/src/app/components/RoomChat.svelte index 5aaabfcf..5703187e 100644 --- a/src/app/components/RoomChat.svelte +++ b/src/app/components/RoomChat.svelte @@ -454,14 +454,18 @@ const onEditPrevious = () => ifLet($events.toReversed().find(canEditEvent), onEditEvent) onMount(() => { - start() + // Defer rendering until navigation finishes + let frame = requestAnimationFrame(() => { + frame = requestAnimationFrame(start) + }) const unsubscribeActive = documentActive.subscribe(onActiveChange) return () => { - // Wrap in a closure to avoid calling a stale cleanup function cleanup?.() unsubscribeActive() + cancelAnimationFrame(frame) + document.removeEventListener("visibilitychange", onVisibilityChange) } })