update app and index.html

This commit is contained in:
2026-06-01 13:15:12 -07:00
parent 254f488eca
commit e0d0f15731
9 changed files with 754 additions and 38 deletions
+45 -4
View File
@@ -12,6 +12,8 @@
homeUi: null,
onStatus: null,
hasTarotAccess: () => false,
shouldPollNow: () => true,
nowPollIntervalMs: 5 * 60 * 1000,
services: {},
ensure: {}
};
@@ -20,6 +22,7 @@
let magickDataset = null;
let currentGeo = null;
let nowInterval = null;
let runtimeListenersBound = false;
let centeredDayKey = "";
let renderInProgress = false;
let currentTimeFormat = "minutes";
@@ -74,11 +77,17 @@
}
function startNowTicker() {
if (nowInterval) {
clearInterval(nowInterval);
}
stopNowTicker();
const pollIntervalMs = Number.isFinite(Number(config.nowPollIntervalMs))
? Math.max(1000, Math.trunc(Number(config.nowPollIntervalMs)))
: 5 * 60 * 1000;
const tick = async () => {
if (config.shouldPollNow?.() === false) {
return;
}
if (!referenceData || !currentGeo || renderInProgress) {
return;
}
@@ -102,7 +111,27 @@
void tick();
nowInterval = setInterval(() => {
void tick();
}, 1000);
}, pollIntervalMs);
}
function stopNowTicker() {
if (!nowInterval) {
return;
}
clearInterval(nowInterval);
nowInterval = null;
}
function syncNowTickerState() {
if (config.shouldPollNow?.() === false) {
stopNowTicker();
return;
}
if (!nowInterval && referenceData && currentGeo) {
startNowTicker();
}
}
async function renderWeek() {
@@ -194,6 +223,18 @@
}
centeredDayKey = config.services.getDateKey?.(new Date()) || centeredDayKey;
if (!runtimeListenersBound) {
document.addEventListener("section:changed", () => {
syncNowTickerState();
});
document.addEventListener("visibilitychange", () => {
syncNowTickerState();
});
runtimeListenersBound = true;
}
}
window.TarotAppRuntime = {