Defer rendering a chat room for a frame

This commit is contained in:
Jon Staab 2026-08-10 15:09:41 -07:00
parent 72ee0c9ed6
commit 8243f4d245

View file

@ -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)
}
})
</script>