fix(workout): skip rest before warmups
This commit is contained in:
1 parent
82f0b84766
commit
b7631dc9a0
2 files changed
+87
-5
No files matched your search
@@ -416,21 +416,24 @@ function ActiveWorkout() {
|
||||
const freshUnitDone = freshUnit?.every(ui => fresh.entries[ui].sets.every(x => x.done))
|
||||
const nextUnit = freshUnitDone ? nextUnfinishedUnit(fresh.entries, freshUnits, idx) : null
|
||||
const freshWorkoutDone = freshUnitDone && !nextUnit
|
||||
const restBeforeWarmup = nextUnit?.some(ui =>
|
||||
fresh.entries[ui].sets.some(set => isWarmupRow(set) && !set.done),
|
||||
)
|
||||
|
||||
// A re-check of finished work must not navigate or reopen a sheet, but it may still owe
|
||||
// you a rest — see restOnRecheck, and the other half of issue #3.
|
||||
if (!progress.isNew) {
|
||||
if (restOnRecheck({ timerRunning: !!useUI.getState().timer, unitDone: freshUnitDone, lastUnit: freshWorkoutDone })) startRest(S.restSec)
|
||||
if (!restBeforeWarmup && restOnRecheck({ timerRunning: !!useUI.getState().timer, unitDone: freshUnitDone, lastUnit: freshWorkoutDone })) startRest(S.restSec)
|
||||
return
|
||||
}
|
||||
|
||||
// Singleton units are ordinary exercises: they rest between sets and after the closing
|
||||
// one, and never enter superset navigation. stopRest() first so the rest that belongs
|
||||
// after this set replaces the one that was running, rather than stacking on it.
|
||||
// one unless the next unit has an unfinished warm-up, and never enter superset navigation.
|
||||
// stopRest() first so a rest that belongs after this set replaces the one that was running.
|
||||
if (freshUnitDone) stopRest()
|
||||
if (!freshUnit || freshUnit.length <= 1) {
|
||||
if (freshUnitDone && !askTop && nextUnit?.length) update(s => { if (s.active) s.active.cur = nextUnit[0] })
|
||||
if (restAfterSet({ unitDone: freshUnitDone, lastUnit: freshWorkoutDone })) startRest(S.restSec)
|
||||
if (!restBeforeWarmup && restAfterSet({ unitDone: freshUnitDone, lastUnit: freshWorkoutDone })) startRest(S.restSec)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -440,7 +443,7 @@ function ActiveWorkout() {
|
||||
if (nextUnit?.length) {
|
||||
// The top-weight sheet's explicit "Just close" path owns the choice not to advance.
|
||||
if (!askTop) update(s => { if (s.active) s.active.cur = nextUnit[0] })
|
||||
startRest(S.restSec)
|
||||
if (!restBeforeWarmup) startRest(S.restSec)
|
||||
}
|
||||
} else {
|
||||
if (step.nextIdx != null) update(s => { if (s.active) s.active.cur = step.nextIdx })
|
||||
|
||||
@@ -169,6 +169,85 @@ describe('Workout set completion flow', () => {
|
||||
expect(mocks.startRest).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it.each(['warmup', 'warm-up', 'warm_up'])(
|
||||
'does not start transition rest before an incomplete %s row in the next ordinary exercise',
|
||||
async phase => {
|
||||
await mount([
|
||||
exercise('current', [false], { asked: true }),
|
||||
exercise('next', [false, false], {
|
||||
asked: true,
|
||||
sets: [
|
||||
{ w: 30, r: 5, done: false, phase },
|
||||
{ w: 60, r: 5, done: false },
|
||||
],
|
||||
}),
|
||||
])
|
||||
|
||||
await toggleSet(0)
|
||||
|
||||
expect(mocks.S.active.cur).toBe(1)
|
||||
expect(mocks.startRest).not.toHaveBeenCalled()
|
||||
},
|
||||
)
|
||||
|
||||
it('does not start transition rest when a completed superset advances to an incomplete warm-up', async () => {
|
||||
await mount([
|
||||
exercise('superset-a', [true], { sg: 'group', asked: true }),
|
||||
exercise('superset-b', [false], { sg: 'group', asked: true }),
|
||||
exercise('next', [false, false], {
|
||||
asked: true,
|
||||
sets: [
|
||||
{ w: 30, r: 5, done: false, phase: 'warmup' },
|
||||
{ w: 60, r: 5, done: false },
|
||||
],
|
||||
}),
|
||||
], 1)
|
||||
|
||||
await toggleSet(1)
|
||||
|
||||
expect(mocks.S.active.cur).toBe(2)
|
||||
expect(mocks.startRest).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('does not start transition rest before a warm-up while top-weight confirmation owns navigation', async () => {
|
||||
await mount([
|
||||
exercise('current-loaded', [false]),
|
||||
exercise('next', [false, false], {
|
||||
asked: true,
|
||||
sets: [
|
||||
{ w: 30, r: 5, done: false, phase: 'warmup' },
|
||||
{ w: 60, r: 5, done: false },
|
||||
],
|
||||
}),
|
||||
])
|
||||
|
||||
await toggleSet(0)
|
||||
|
||||
expect(mocks.topWeightSheet).toHaveBeenCalledWith(0)
|
||||
expect(mocks.S.active.cur).toBe(0)
|
||||
expect(mocks.startRest).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('does not restart transition rest when re-checking a completed unit before an incomplete warm-up', async () => {
|
||||
await mount([
|
||||
exercise('current', [true], { asked: true }),
|
||||
exercise('next', [false, false], {
|
||||
asked: true,
|
||||
sets: [
|
||||
{ w: 30, r: 5, done: false, phase: 'warmup' },
|
||||
{ w: 60, r: 5, done: false },
|
||||
],
|
||||
}),
|
||||
])
|
||||
|
||||
await toggleSet(0)
|
||||
await rerender()
|
||||
await toggleSet(0)
|
||||
|
||||
expect(mocks.S.active.cur).toBe(0)
|
||||
expect(mocks.startRest).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('leaves a completed superset selected while its top-weight sheet owns the advance choice', async () => {
|
||||
const group = 'superset-1'
|
||||
await mount([
|
||||
|
||||
Reference in new issue
Block a user