Open-source gym & body-weight tracker, now in the App Store (iPhone + Apple Watch) and as an Android APK. Plan routines, log workouts, see which muscles are trained, import from Strong/Hevy/FitNotes. Self-host it or use it on the phone alone.
JavaScript apple-watchbodyweightdockerfitnessfitness-trackergymhealthiosmcpnodejspasskeysprogressive-web-applicationspwareactself-hostedself-hostingvitewebauthnweightliftingworkout-tracker
timer: a rest that never starts leaves a running hold alone
Boris 'B' Kurktchiev39daa2c8a9dd
diff --git a/frontend/src/store/useUI.js b/frontend/src/store/useUI.jsindex ae8380ee1..41ec61fc4 100644--- a/frontend/src/store/useUI.js+++ b/frontend/src/store/useUI.js@@ -89,15 +89,17 @@ export const useUI = create((set, get) => ({startRest(sec, forIdx) {get().stopRest()+ // Rest timer set to Off. Stopping and returning rather than starting a zero-length timer+ // keeps every caller honest: the four places that start a rest do not each need to know.+ if (!(sec > 0)) return// And the hold, the other way round from startWork: the two must never run together (see the// work timer below). A set ticked by hand while its hold ran used to leave both going — the// rest bar with its Skip and ±15 s hidden behind the hold bar, and then the hold reaching// zero under a rest that was still counting down, beeping its own end and logging the full- // target for a set nobody was holding any more.+ // target for a set nobody was holding any more. Below the guard, not above it: a rest that+ // does not start has nothing to run alongside the hold, and taking the hold down for it+ // would throw away a plank in progress for nothing.get().stopWork()- // Rest timer set to Off. Stopping and returning rather than starting a zero-length timer- // keeps every caller honest: the four places that start a rest do not each need to know.- if (!(sec > 0)) return// Nothing clears pageHiddenAt but a tick, so an app switch with no timer running left it set// for good. The next timer's first tick then read it as "this countdown ran out while the app// was away" and finished in silence — a one-second rest, started on screen, over on screen,diff --git a/frontend/src/store/useUI.test.js b/frontend/src/store/useUI.test.jsindex df8de7b4c..61e944346 100644--- a/frontend/src/store/useUI.test.js+++ b/frontend/src/store/useUI.test.js@@ -26,6 +26,16 @@ describe('rest timer set to Off', () => {useUI.getState().startRest(90)expect(useUI.getState().timer.total).toBe(90)})++ // A rest that does not start has nothing to run alongside a hold, so it leaves it alone: with+ // the timer Off, ticking a set somewhere must not throw away a plank in progress.+ it('leaves a running hold alone — there is no rest for it to clash with', () => {+ useUI.getState().startWork(45, 'Plank', vi.fn())+ useUI.getState().startRest(0, 1)+ expect(useUI.getState().work).not.toBe(null)+ expect(useUI.getState().work.total).toBe(45)+ useUI.getState().stopWork()+ })})describe('opt-in timer screen flash', () => {