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
Plan: taking the last routine out of the loop stays on Rotation
Duarte Santosd920a90f525c
diff --git a/frontend/src/views/Plan.jsx b/frontend/src/views/Plan.jsxindex 2a3276c52..94ef22e87 100644--- a/frontend/src/views/Plan.jsx+++ b/frontend/src/views/Plan.jsx@@ -120,10 +120,15 @@ function Schedule({ S, update, nav, mode }) {}const setSeq = ids => update(s => {- // Emptying the sequence is how you leave the rotation from here: no pass, no definition, and- // the weekday plan — untouched all along — is the schedule again.+ // Emptying the sequence stops the pass but stays on Rotation with an empty loop ('No rotation+ // yet'), so taking out the last routine to swap it for another never throws you onto the+ // weekday grid. Leaving the rotation is the 'How you train' switch's job.if (ids.length) saveRotation(s, ids, seqLabel)- else { stopPass(s); s.rotation = null; s.scheduleMode = 'week' }+ else {+ stopPass(s)+ if (s.rotation) s.rotation = { ...s.rotation, sequence: [] }+ s.scheduleMode = 'rotation'+ }})const loopReorder = useListReorder(seq.length, (from, to) => setSeq(moved(seq, from, to)))const addToSeq = () => menuSheet({diff --git a/frontend/src/views/Plan.rotation.test.jsx b/frontend/src/views/Plan.rotation.test.jsxindex f39d1182b..3cc4bc45f 100644--- a/frontend/src/views/Plan.rotation.test.jsx+++ b/frontend/src/views/Plan.rotation.test.jsx@@ -189,7 +189,7 @@ describe('Plan — the loop', () => {expect(mocks.S.queue.ids).toEqual(['c', 'a', 'b'])})- it('removing the last routine hands the schedule back to the weekday plan', () => {+ it('removing the last routine keeps Rotation with an empty loop, ready for another routine', () => {mount({ queue: live({ ids: ['a'], rotationId: 'r1' }), rotation: { id: 'r1', sequence: ['a'], label: 'My split' } })click(byLabel('Edit'))const minus = rows()[0].querySelector('.plan-minus')@@ -197,9 +197,17 @@ describe('Plan — the loop', () => {expect(host.textContent).toContain('Drag to reorder. Tap the minus to take one out.')click(minus)expect(mocks.S.queue).toBe(null)- expect(mocks.S.rotation).toBe(null)- expect(mocks.S.scheduleMode).toBe('week')+ expect(mocks.S.rotation).toEqual({ id: 'r1', sequence: [], label: 'My split' })+ expect(mocks.S.scheduleMode).toBe('rotation')expect(mocks.S.week).toEqual({ 1: ['c'] })+ remount()+ expect(selectedMode()).toBe('Rotation')+ expect(host.textContent).toContain('No rotation yet.')+ // swapping the only routine: add another one back in, same rotation id+ click(byLabel('Add routine to the rotation'))+ act(() => menuSheet.mock.calls.at(-1)[0].items.find(i => i.label === 'B').onClick())+ expect(mocks.S.rotation).toMatchObject({ id: 'r1', sequence: ['b'] })+ expect(mocks.S.queue.ids).toEqual(['b'])})it('Start the loop over rewinds the current round, strictly from now', () => {