From 10791893815617642de98705d2dc3de73d58327f Mon Sep 17 00:00:00 2001 From: Přemysl Eric Janouch
Date: Tue, 24 Jan 2023 08:02:08 +0100 Subject: xP: render date changes as they happen --- xP/public/xP.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'xP') 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 => { -- cgit v1.2.3-70-g09d2