summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2023-01-24 08:02:08 +0100
committerPřemysl Eric Janouch <p@janouch.name>2023-01-25 00:31:57 +0100
commit10791893815617642de98705d2dc3de73d58327f (patch)
tree0d869af2e5d0098cf47b9293e6789a14ad0f7d0a
parentc58b7729056c74e1e76fe41f5291ad73773b442e (diff)
downloadxK-10791893815617642de98705d2dc3de73d58327f.tar.gz
xK-10791893815617642de98705d2dc3de73d58327f.tar.xz
xK-10791893815617642de98705d2dc3de73d58327f.zip
xP: render date changes as they happen
-rw-r--r--xP/public/xP.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/xP/public/xP.js b/xP/public/xP.js
index 8a117f0..61238c5 100644
--- a/xP/public/xP.js
+++ b/xP/public/xP.js
@@ -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 => {