pace: fix reading of state

master
Rob Pilling 2025-06-04 21:16:28 +01:00
parent 1d0f21b248
commit f3cbe69240
1 changed files with 6 additions and 2 deletions

View File

@ -25,7 +25,11 @@ type Split = {
time: Time,
};
const splits: Split[] = (S.readJSON("pace.json", 1) as Split[]) || []; // times
type PaceState = { splits: Split[] };
const splits: PaceState["splits"] =
(S.readJSON("pace.json", 1) as PaceState | undefined)?.splits || [];
let splitOffset = 0, splitOffsetPx = 0;
const GPS_TIMEOUT_MS = 30000;
@ -245,7 +249,7 @@ exs.stats.dist.on("notify", (dist) => {
// subtract <how much we're over> off the next split notify
exs.state.notify.dist.next -= thisSplit;
S.writeJSON("pace.json", { splits });
S.writeJSON("pace.json", { splits } satisfies PaceState);
});
Bangle.on('lock', locked => {