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 starting ends the hold, not just the other way round
Boris 'B' Kurktchievc5052af644d2
diff --git a/frontend/src/store/useUI.js b/frontend/src/store/useUI.jsindex 01e1fc70f..01ce0feba 100644--- a/frontend/src/store/useUI.js+++ b/frontend/src/store/useUI.js@@ -89,6 +89,12 @@ export const useUI = create((set, get) => ({startRest(sec, forIdx) {get().stopRest()+ // 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.+ 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)) returndiff --git a/frontend/src/store/useUI.test.js b/frontend/src/store/useUI.test.jsindex 2d7d2e33b..89f936d2f 100644--- a/frontend/src/store/useUI.test.js+++ b/frontend/src/store/useUI.test.js@@ -96,3 +96,32 @@ describe('opt-in timer screen flash', () => {expect(useUI.getState().timerFlashId).toBe(1)})})++// The rest and the hold mean opposite things and the store has always said so, but only+// startWork enforced it. Ticking a timed set's own checkbox by hand starts a rest+// (Workout.toggle) while the hold is still running, which left both going.+describe('a rest and a hold never run together', () => {+ beforeEach(() => { vi.useFakeTimers(); useUI.setState({ timer: null, work: null }) })+ afterEach(() => {+ useUI.getState().stopRest()+ useUI.getState().stopWork()+ vi.useRealTimers()+ })++ it('a rest starting ends the hold, the way a hold starting ends the rest', () => {+ useUI.getState().startWork(45, 'Plank', vi.fn())+ useUI.getState().startRest(90, 0)+ expect(useUI.getState().work).toBe(null)+ expect(useUI.getState().timer).not.toBe(null)+ })++ it('so a left-over hold cannot reach zero under a running rest and log a set nobody held', () => {+ const holdDone = vi.fn()+ useUI.getState().startWork(3, 'Plank', holdDone)+ useUI.getState().startRest(90, 0)+ vi.advanceTimersByTime(3000) // where the hold would have run out+ expect(useUI.getState().timer.left).toBe(87) // the rest is still counting, untouched+ expect(useUI.getState().work).toBe(null)+ expect(holdDone).not.toHaveBeenCalled()+ })+})