aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 => {