xP: render date changes as they happen

This commit is contained in:
Přemysl Eric Janouch 2023-01-24 08:02:08 +01:00
parent c58b772905
commit 1079189381
Signed by: p
GPG Key ID: A0420B94F92B9493
1 changed files with 14 additions and 0 deletions

View File

@ -586,10 +586,24 @@ let Buffer = {
vnode.state.controller = new AbortController()
window.addEventListener('resize', event => Buffer.onupdate(vnode),
{signal: vnode.state.controller.signal})
Buffer.setDateChangeTimeout(vnode)
},
onremove: vnode => {
vnode.state.controller.abort()
clearTimeout(vnode.state.dateChangeTimeout)
},
setDateChangeTimeout: vnode => {
let midnight = new Date()
midnight.setHours(24, 0, 0, 0)
// Note that this doesn't handle time zone changes correctly.
vnode.state.dateChangeTimeout = setTimeout(() => {
m.redraw()
Buffer.setDateChangeTimeout(vnode)
}, midnight - new Date())
},
view: vnode => {