From db13056723c0c13fcf9ea98ed258a619f9654ab8 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Mon, 16 Nov 2026 17:24:13 +0100 Subject: fix(xbox): a redrawn hold never fires, and start clears the flag A power button rebuilt mid-hold lost its pointerup, so letting go early still turned the console off; hold.js now drops a hold whose button is no longer in the page. status.xbox is written 0 on start, in case a crash left it at 1. The "ago" texts move on each minute, and missing storage names and achievement percentages no longer print null. Co-Authored-By: Claude Opus 5.5 --- static/modules/xbox.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'static/modules/xbox.js') diff --git a/static/modules/xbox.js b/static/modules/xbox.js index 7e2f075..ec4a14a 100644 --- a/static/modules/xbox.js +++ b/static/modules/xbox.js @@ -113,7 +113,7 @@ function consoleCard(c) { for (const d of c.storage ?? []) { const row = h("div", "xb-disk"); const used = d.total ? (d.total - d.free) / d.total : 0; - row.append(h("span", "", `${d.name} · ${gb(d.free)} free of ${gb(d.total)}`)); + row.append(h("span", "", `${d.name ?? ""} · ${gb(d.free)} free of ${gb(d.total)}`)); const bar = h("div", "gbar"); bar.append(h("i")); bar.firstChild.style.width = `${Math.round(used * 100)}%`; @@ -144,10 +144,10 @@ function nowPlaying(st) { h("div", "xb-nrich", g.rich ?? ""), h("div", "xb-clock num", clock(st.session))); if (t) { const a = t.achievements; - info.append(h("div", "xb-nach", `${a.score} / ${a.max} G · ${Math.round(a.pct)}%`)); + info.append(h("div", "xb-nach", `${a.score} / ${a.max} G · ${Math.round(a.pct ?? 0)}%`)); const bar = h("div", "gbar"); bar.append(h("i")); - bar.firstChild.style.width = `${a.pct}%`; + bar.firstChild.style.width = `${a.pct ?? 0}%`; info.append(bar); } card.append(info); @@ -161,7 +161,7 @@ function gameTile(t) { const a = t.achievements; const bar = h("div", "gbar"); bar.append(h("i")); - bar.firstChild.style.width = `${a.pct}%`; + bar.firstChild.style.width = `${a.pct ?? 0}%`; tile.append(bar, h("div", "xb-gmeta", [`${a.score}/${a.max} G`, hours(t.minutes)].filter(Boolean).join(" · "))); } else { tile.append(h("div", "xb-gmeta", ago(t.last))); @@ -261,8 +261,9 @@ export default { } // Drawn again only when the data changed: a redraw restarts the images // and would cut a held power button short. - // ponytail: a hold across a 30s data change still restarts; key per card if it bites. - const key = JSON.stringify(st); + // ponytail: a hold across a data change is dropped (hold.js); key per card if it bites. + // The minute is in the key so the "ago" texts move on with idle data. + const key = JSON.stringify(st) + Math.floor(Date.now() / 60000); if (on._key !== key) { on._key = key; if (st.signed_in === false) signIn(on, st); -- cgit v1.2.3