Defer rendering a chat room for a frame
This commit is contained in:
parent
72ee0c9ed6
commit
8243f4d245
1 changed files with 6 additions and 2 deletions
|
|
@ -454,14 +454,18 @@
|
||||||
const onEditPrevious = () => ifLet($events.toReversed().find(canEditEvent), onEditEvent)
|
const onEditPrevious = () => ifLet($events.toReversed().find(canEditEvent), onEditEvent)
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
start()
|
// Defer rendering until navigation finishes
|
||||||
|
let frame = requestAnimationFrame(() => {
|
||||||
|
frame = requestAnimationFrame(start)
|
||||||
|
})
|
||||||
|
|
||||||
const unsubscribeActive = documentActive.subscribe(onActiveChange)
|
const unsubscribeActive = documentActive.subscribe(onActiveChange)
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
// Wrap in a closure to avoid calling a stale cleanup function
|
|
||||||
cleanup?.()
|
cleanup?.()
|
||||||
unsubscribeActive()
|
unsubscribeActive()
|
||||||
|
cancelAnimationFrame(frame)
|
||||||
|
document.removeEventListener("visibilitychange", onVisibilityChange)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue