curated2: !34
This commit is contained in:
commit
adc655ebd3
18 files changed
+159
-13
No files matched your search
@@ -44,6 +44,10 @@ function cleanEx(e) {
|
||||
if (e.inc > 0) o.inc = e.inc
|
||||
if (e.repsMin != null) o.repsMin = e.repsMin
|
||||
if (e.repsMax != null) o.repsMax = e.repsMax
|
||||
// The exercise's own rest (issue #10) is part of how it is prescribed, so it travels too —
|
||||
// only when set, so a plan that never asked for one leaves the recipient's own default
|
||||
// timer in charge. parsePlan and mergePlan carry it through by spread.
|
||||
if (e.restSec > 0) o.restSec = e.restSec
|
||||
if (e.sg) o.sg = e.sg
|
||||
if (e.note) o.note = e.note
|
||||
const warm = cleanWarmupSets(e.warmupSets)
|
||||
@@ -63,6 +67,13 @@ function cleanWarmupSets(v) {
|
||||
return n > 0 ? Math.min(MAX_PLANNED_WARMUPS, n) : 0
|
||||
}
|
||||
|
||||
/** A positive whole number of seconds or nothing — the same gate cleanEx applies on the way
|
||||
* out, so a hand-edited plan file can't hand the rest timer a string or a negative. */
|
||||
function cleanRestSec(v) {
|
||||
const n = Math.round(Number(v)) || 0
|
||||
return n > 0 ? n : 0
|
||||
}
|
||||
|
||||
/** Keep the floors the config sheet and applyIntensifierPlan already enforce, and nothing else:
|
||||
* a plan file is someone else's data, so anything unrecognised is dropped rather than trusted. */
|
||||
function cleanIntensifier(x) {
|
||||
@@ -117,12 +128,13 @@ export function parsePlan(raw) {
|
||||
if (!ok) dropped++
|
||||
return ok
|
||||
}).map(e => {
|
||||
// The exercises pass through as written, so the two fields that carry numbers into the
|
||||
// The exercises pass through as written, so the fields that carry numbers into the
|
||||
// planner get the same clamps on the way in that they get on the way out.
|
||||
const warm = cleanWarmupSets(e.warmupSets)
|
||||
const intens = cleanIntensifier(e.intensifier)
|
||||
const { warmupSets, intensifier, ...rest } = e
|
||||
return { ...rest, ...(warm ? { warmupSets: warm } : {}), ...(intens ? { intensifier: intens } : {}) }
|
||||
const rest = cleanRestSec(e.restSec)
|
||||
const { warmupSets, intensifier, restSec, ...passthrough } = e
|
||||
return { ...passthrough, ...(warm ? { warmupSets: warm } : {}), ...(intens ? { intensifier: intens } : {}), ...(rest ? { restSec: rest } : {}) }
|
||||
})
|
||||
}))
|
||||
return {
|
||||
|
||||
@@ -35,6 +35,26 @@ describe('what survives a shared plan', () => {
|
||||
expect(target.routines[0].excludeFromProgression).toBe(true)
|
||||
})
|
||||
|
||||
// Issue #10: the rest an exercise prescribes is part of the prescription. A shared 5x5 whose
|
||||
// rests arrive as the recipient's 60 s default is a different session than the one written.
|
||||
it('carries a per-exercise rest', () => {
|
||||
expect(roundTrip({ restSec: 180 }).restSec).toBe(180)
|
||||
})
|
||||
|
||||
// The absence has to survive too: writing a 0 would pin the recipient's timer to "off"
|
||||
// instead of letting the exercise keep inheriting whatever their own default is.
|
||||
it('leaves an exercise that set no rest free of the field', () => {
|
||||
expect('restSec' in roundTrip({})).toBe(false)
|
||||
expect('restSec' in roundTrip({ restSec: 0 })).toBe(false)
|
||||
})
|
||||
|
||||
it('carries the rest onto the routine mergePlan adds', () => {
|
||||
const bundle = parsePlan(JSON.stringify(buildPlanBundle(stateWith({ restSec: 180 }), 'Plan')))
|
||||
const s = { routines: [], customEx: [], week: {} }
|
||||
mergePlan(s, bundle, { schedule: false })
|
||||
expect(s.routines[0].ex[0].restSec).toBe(180)
|
||||
})
|
||||
|
||||
it('drops an intensifier it does not recognise rather than passing it on', () => {
|
||||
expect(roundTrip({ intensifier: { type: 'nonsense', count: 3 } }).intensifier).toBeUndefined()
|
||||
})
|
||||
@@ -44,6 +64,16 @@ describe('what survives a shared plan', () => {
|
||||
expect(parsePlan(bundle).routines[0].ex[0].warmupSets).toBe(5)
|
||||
})
|
||||
|
||||
// A plan file is someone else's data: a rest that arrives as a string would reach the timer's
|
||||
// arithmetic as one, and a negative or garbage one has no meaning to keep.
|
||||
it('normalises a hand-edited rest to a positive whole number or drops it', () => {
|
||||
const withRest = restSec => ({ opengym_plan: 1, name: 'x', routines: [{ id: 'r', name: 'R', ex: [{ id: '0025', sets: 3, reps: 5, restSec }] }], week: {}, customEx: [] })
|
||||
expect(parsePlan(withRest('120')).routines[0].ex[0].restSec).toBe(120)
|
||||
expect(parsePlan(withRest(90.6)).routines[0].ex[0].restSec).toBe(91)
|
||||
expect('restSec' in parsePlan(withRest(-30)).routines[0].ex[0]).toBe(false)
|
||||
expect('restSec' in parsePlan(withRest('abc')).routines[0].ex[0]).toBe(false)
|
||||
})
|
||||
|
||||
// The floors are the config sheet's own (count >= 1, pct >= 5); a value that is present but
|
||||
// out of range is pulled up to the floor, while a missing one falls back to the default.
|
||||
it('clamps out-of-range intensifier numbers to the floors the app enforces', () => {
|
||||
|
||||
@@ -63,6 +63,32 @@ export function restOnRecheck({ timerRunning, unitDone, lastUnit }) {
|
||||
return !timerRunning && restAfterSet({ unitDone, lastUnit })
|
||||
}
|
||||
|
||||
/**
|
||||
* How long the rest after a completed set should run, in seconds.
|
||||
*
|
||||
* An exercise may carry its own `restSec` in its target (issue #10) — a heavy triple and a set
|
||||
* of curls do not want the same break. One that carries none inherits `defaultRestSec`, the
|
||||
* global rest timer, which is what every routine did before the field existed.
|
||||
*
|
||||
* `unit` is the superset group the set belongs to, as entry indices — a plain exercise is a
|
||||
* group of one. A group rests once, after the round, so it takes the LONGEST rest any of its
|
||||
* members asked for: the shortest would send you back to the bar before the member that needs
|
||||
* the most recovery is ready.
|
||||
*
|
||||
* `defaultRestSec` of 0 is the rest timer turned off (v1.2.11). That silences the members that
|
||||
* have no rest of their own, but an exercise that explicitly asks for one still gets it — the
|
||||
* setting is a default, and this field overrides the default.
|
||||
*/
|
||||
export function restSecFor(entries, unit, defaultRestSec) {
|
||||
const fallback = defaultRestSec > 0 ? defaultRestSec : 0
|
||||
const idxs = Array.isArray(unit) && unit.length ? unit : []
|
||||
if (!idxs.length) return fallback
|
||||
return idxs.reduce((longest, idx) => {
|
||||
const own = entries?.[idx]?.target?.restSec
|
||||
return Math.max(longest, own > 0 ? own : fallback)
|
||||
}, 0)
|
||||
}
|
||||
|
||||
// Decide where a newly completed superset set goes next. Spent members are skipped, including
|
||||
// across the wrap. A round ends when no later member in display order has work left; this makes
|
||||
// the last *active* member the boundary rather than blindly using the group's last array index.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { insertionIndexAfterCurrentUnit, nextUnfinishedUnit, setProgressHighWater, supersetFlowStep, restAfterSet, restOnRecheck } from './supersetFlow.js'
|
||||
import { insertionIndexAfterCurrentUnit, nextUnfinishedUnit, setProgressHighWater, supersetFlowStep, restAfterSet, restOnRecheck, restSecFor } from './supersetFlow.js'
|
||||
|
||||
const entry = done => ({ sets: done.map(value => ({ done: value })) })
|
||||
|
||||
@@ -92,3 +92,48 @@ describe('rest on a re-check', () => {
|
||||
expect(restOnRecheck({ timerRunning: false, unitDone: true, lastUnit: false })).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
// Issue #10: a routine can give an exercise its own rest, and the global timer stops being the
|
||||
// only answer. The resolution is the whole feature — the UI just writes the number down.
|
||||
describe('restSecFor', () => {
|
||||
// 0: no rest of its own, 1: 180 s, 2: 45 s — a heavy pull, a light accessory, a plain one.
|
||||
const entries = [
|
||||
{ id: 'a', target: { mode: 'reps' } },
|
||||
{ id: 'b', target: { mode: 'reps', restSec: 180 } },
|
||||
{ id: 'c', target: { mode: 'reps', restSec: 45 } },
|
||||
]
|
||||
|
||||
it('prefers the exercise’s own rest over the global default', () => {
|
||||
expect(restSecFor(entries, [1], 90)).toBe(180)
|
||||
expect(restSecFor(entries, [2], 90)).toBe(45)
|
||||
})
|
||||
|
||||
it('falls back to the global default when the exercise sets none', () => {
|
||||
expect(restSecFor(entries, [0], 90)).toBe(90)
|
||||
})
|
||||
|
||||
it('gives a superset the longest rest its members asked for', () => {
|
||||
// Not the member that closed the round, and not the shortest: the group rests once, and
|
||||
// the 180 s exercise is the one still recovering when the 45 s one is ready to go again.
|
||||
expect(restSecFor(entries, [1, 2], 90)).toBe(180)
|
||||
// A member with no rest of its own pulls in the global, which can be the longest of all.
|
||||
expect(restSecFor(entries, [0, 2], 90)).toBe(90)
|
||||
})
|
||||
|
||||
it('honours an explicit rest even with the global timer switched off', () => {
|
||||
expect(restSecFor(entries, [1], 0)).toBe(180)
|
||||
expect(restSecFor(entries, [0, 1], 0)).toBe(180)
|
||||
})
|
||||
|
||||
it('stays off when the timer is off and nothing asked for a rest', () => {
|
||||
expect(restSecFor(entries, [0], 0)).toBe(0)
|
||||
expect(restSecFor(entries, [0, 0], 0)).toBe(0)
|
||||
})
|
||||
|
||||
it('survives a missing unit or entry rather than timing NaN', () => {
|
||||
expect(restSecFor(entries, null, 90)).toBe(90)
|
||||
expect(restSecFor(entries, [], 90)).toBe(90)
|
||||
expect(restSecFor(entries, [7], 90)).toBe(90)
|
||||
expect(restSecFor(undefined, [0], undefined)).toBe(0)
|
||||
})
|
||||
})
|
||||
@@ -185,6 +185,7 @@ export default {
|
||||
'Remove drop': 'Dropsatz entfernen',
|
||||
'Remove burst': 'Burst entfernen',
|
||||
'Rest (s)': 'Pause (s)',
|
||||
'Rest after each set of this exercise. Leave at 0 to use your default rest timer.': 'Pause nach jedem Satz dieser Übung. Auf 0 lassen, um den Standard-Pausen-Timer zu nutzen.',
|
||||
'Drop-set / rest-pause': 'Dropsatz / Rest-Pause',
|
||||
'Intensifier': 'Intensivierungstechnik',
|
||||
'None': 'Keine',
|
||||
|
||||
@@ -178,6 +178,7 @@ export default {
|
||||
'Remove drop': 'Quitar bajada',
|
||||
'Remove burst': 'Quitar ráfaga',
|
||||
'Rest (s)': 'Descanso (s)',
|
||||
'Rest after each set of this exercise. Leave at 0 to use your default rest timer.': 'Descanso tras cada serie de este ejercicio. Déjalo en 0 para usar tu temporizador de descanso por defecto.',
|
||||
'Drop-set / rest-pause': 'Series descendentes / rest-pause',
|
||||
'Intensifier': 'Intensificador',
|
||||
'None': 'Ninguno',
|
||||
|
||||
@@ -178,6 +178,7 @@ export default {
|
||||
'Remove drop': 'Retirer le drop set',
|
||||
'Remove burst': 'Retirer la rafale',
|
||||
'Rest (s)': 'Repos (s)',
|
||||
'Rest after each set of this exercise. Leave at 0 to use your default rest timer.': 'Repos après chaque série de cet exercice. Laisse à 0 pour utiliser ton minuteur de repos par défaut.',
|
||||
'Drop-set / rest-pause': 'Drop-set / rest-pause',
|
||||
'Intensifier': 'Intensificateur',
|
||||
'None': 'Aucun',
|
||||
|
||||
@@ -178,6 +178,7 @@ export default {
|
||||
'Remove drop': 'ड्रॉप सेट हटाएं',
|
||||
'Remove burst': 'बर्स्ट हटाएं',
|
||||
'Rest (s)': 'आराम (सेकंड)',
|
||||
'Rest after each set of this exercise. Leave at 0 to use your default rest timer.': 'इस एक्सरसाइज़ के हर सेट के बाद आराम। अपना डिफ़ॉल्ट आराम टाइमर इस्तेमाल करने के लिए इसे 0 रहने दें।',
|
||||
'Drop-set / rest-pause': 'ड्रॉप सेट / रेस्ट-पॉज़',
|
||||
'Intensifier': 'इंटेंसिफायर',
|
||||
'None': 'कोई नहीं',
|
||||
|
||||
@@ -178,6 +178,7 @@ export default {
|
||||
'Remove drop': 'Rimuovi drop set',
|
||||
'Remove burst': 'Rimuovi burst',
|
||||
'Rest (s)': 'Recupero (s)',
|
||||
'Rest after each set of this exercise. Leave at 0 to use your default rest timer.': 'Recupero dopo ogni serie di questo esercizio. Lascialo a 0 per usare il timer di riposo predefinito.',
|
||||
'Drop-set / rest-pause': 'Drop-set / rest-pause',
|
||||
'Intensifier': 'Intensificatore',
|
||||
'None': 'Nessuno',
|
||||
|
||||
@@ -178,6 +178,7 @@ export default {
|
||||
'Remove drop': '드롭세트 제거',
|
||||
'Remove burst': '버스트 제거',
|
||||
'Rest (s)': '휴식(초)',
|
||||
'Rest after each set of this exercise. Leave at 0 to use your default rest timer.': '이 운동의 세트마다 갖는 휴식이에요. 기본 휴식 타이머를 쓰려면 0으로 두세요.',
|
||||
'Drop-set / rest-pause': '드롭세트 / 레스트포즈',
|
||||
'Intensifier': '강도 기법',
|
||||
'None': '없음',
|
||||
|
||||
@@ -178,6 +178,7 @@ export default {
|
||||
'Remove drop': 'Usuń serię zniżkującą',
|
||||
'Remove burst': 'Usuń serię rest-pause',
|
||||
'Rest (s)': 'Odpoczynek (s)',
|
||||
'Rest after each set of this exercise. Leave at 0 to use your default rest timer.': 'Odpoczynek po każdej serii tego ćwiczenia. Zostaw 0, żeby użyć domyślnego minutnika przerwy.',
|
||||
'Drop-set / rest-pause': 'Seria zniżkująca / rest-pause',
|
||||
'Intensifier': 'Technika intensyfikująca',
|
||||
'None': 'Brak',
|
||||
|
||||
@@ -341,7 +341,10 @@ export const PT_BR_OVERRIDES = {
|
||||
'Brings it up again the next time you train this exercise.': 'Aparece de novo na próxima vez que você treinar este exercício.',
|
||||
'Seat height, pin position, a form cue — shown every session.': 'Altura do banco, posição do pino, uma dica de execução — aparece em todos os treinos.',
|
||||
'How the session went as a whole.': 'Como foi o treino como um todo.',
|
||||
'Rest-pause always trains as one warm-up set at this rep count, then one rest-pause work set — "Sets" is not used.': 'O rest-pause sempre treina como uma série de aquecimento com essas repetições e uma série de trabalho rest-pause — “Séries” não é usado.'
|
||||
'Rest-pause always trains as one warm-up set at this rep count, then one rest-pause work set — "Sets" is not used.': 'O rest-pause sempre treina como uma série de aquecimento com essas repetições e uma série de trabalho rest-pause — “Séries” não é usado.',
|
||||
|
||||
// --- per-exercise rest ---
|
||||
'Rest after each set of this exercise. Leave at 0 to use your default rest timer.': 'Descanso depois de cada série deste exercício. Deixe em 0 para usar o temporizador de descanso padrão.'
|
||||
}
|
||||
|
||||
export default { ...pt, ...PT_BR_OVERRIDES }
|
||||
@@ -178,6 +178,7 @@ export default {
|
||||
'Remove drop': 'Remover queda',
|
||||
'Remove burst': 'Remover rajada',
|
||||
'Rest (s)': 'Descanso (s)',
|
||||
'Rest after each set of this exercise. Leave at 0 to use your default rest timer.': 'Descanso depois de cada série deste exercício. Deixa a 0 para usares o temporizador de descanso predefinido.',
|
||||
'Drop-set / rest-pause': 'Séries decrescentes / rest-pause',
|
||||
'Intensifier': 'Intensificador',
|
||||
'None': 'Nenhum',
|
||||
|
||||
@@ -178,6 +178,7 @@ export default {
|
||||
'Remove drop': 'Убрать дроп-сет',
|
||||
'Remove burst': 'Убрать серию',
|
||||
'Rest (s)': 'Отдых (с)',
|
||||
'Rest after each set of this exercise. Leave at 0 to use your default rest timer.': 'Отдых после каждого подхода этого упражнения. Оставь 0, чтобы работал таймер отдыха по умолчанию.',
|
||||
'Drop-set / rest-pause': 'Дроп-сет / рест-пауза',
|
||||
'Intensifier': 'Интенсификатор',
|
||||
'None': 'Нет',
|
||||
|
||||
@@ -178,6 +178,7 @@ export default {
|
||||
'Remove drop': 'Düşüş setini kaldır',
|
||||
'Remove burst': 'Patlamayı kaldır',
|
||||
'Rest (s)': 'Dinlenme (sn)',
|
||||
'Rest after each set of this exercise. Leave at 0 to use your default rest timer.': 'Bu egzersizin her setinden sonraki dinlenme. Varsayılan dinlenme sayacını kullanmak için 0 bırak.',
|
||||
'Drop-set / rest-pause': 'Düşüş seti / rest-pause',
|
||||
'Intensifier': 'Yoğunlaştırıcı',
|
||||
'None': 'Yok',
|
||||
|
||||
@@ -178,6 +178,7 @@ export default {
|
||||
'Remove drop': '移除递减组',
|
||||
'Remove burst': '移除爆发组',
|
||||
'Rest (s)': '休息(秒)',
|
||||
'Rest after each set of this exercise. Leave at 0 to use your default rest timer.': '这个动作每组之后的休息时间。留在 0 就使用默认的休息计时。',
|
||||
'Drop-set / rest-pause': '递减组 / 歇息暂停组',
|
||||
'Intensifier': '强化技巧',
|
||||
'None': '无',
|
||||
|
||||
+18
-3
@@ -884,14 +884,19 @@ function ExConfig({ ex, existing, onSave, onDelete, close, routine, initial }) {
|
||||
// shape it had — and reads back as 0 either way (buildSets).
|
||||
const warmupSets = Math.max(0, Math.min(MAX_PLANNED_WARMUPS, Math.round(c.warmupSets) || 0))
|
||||
const withWarmups = warmupSets ? { warmupSets } : {}
|
||||
if (cardio) onSave({ sets, min: Math.max(1, Math.round(c.min) || 20), speed: Math.max(0, c.speed || 8), ...withNote })
|
||||
else if (mode === 'time') onSave({ sets, mode: 'time', sec: Math.max(1, Math.round(c.sec) || 45), weight: Math.max(0, c.weight || 0), ...flags, ...prog, ...withNote, ...withWarmups })
|
||||
// Per-exercise rest (issue #10): written only when a positive value was set, so 0 keeps
|
||||
// inheriting the global rest timer and a config that never touched it stays the shape it
|
||||
// was. Mode-independent — a heavy triple, a plank and a cardio interval all rest.
|
||||
const restSec = Math.max(0, Math.round(c.restSec) || 0)
|
||||
const withRest = restSec ? { restSec } : {}
|
||||
if (cardio) onSave({ sets, min: Math.max(1, Math.round(c.min) || 20), speed: Math.max(0, c.speed || 8), ...withNote, ...withRest })
|
||||
else if (mode === 'time') onSave({ sets, mode: 'time', sec: Math.max(1, Math.round(c.sec) || 45), weight: Math.max(0, c.weight || 0), ...flags, ...prog, ...withNote, ...withWarmups, ...withRest })
|
||||
else {
|
||||
// A unilateral target is stored even: the split has to divide, and a typed 15 would
|
||||
// otherwise plan seven reps on one side and eight on the other, every session.
|
||||
const typed = Math.max(1, Math.round(c.reps) || 10)
|
||||
const reps = perSide ? Math.ceil(typed / 2) * 2 : typed
|
||||
const out = { sets, mode: 'reps', reps, weight: Math.max(0, c.weight || 0), ...flags, ...(perSide ? { side: true } : {}), ...prog, ...withNote, ...withWarmups }
|
||||
const out = { sets, mode: 'reps', reps, weight: Math.max(0, c.weight || 0), ...flags, ...(perSide ? { side: true } : {}), ...prog, ...withNote, ...withWarmups, ...withRest }
|
||||
if (policyFor({ ...c, id: ex.id }, routine, 'reps') === 'double') out.repsMin = Math.min(reps, Math.max(1, Math.round(c.repsMin) || Math.max(1, reps - 2)))
|
||||
// A ceiling below the working reps would tell you to add a set on day one.
|
||||
if (bw && !(out.weight > 0) && c.repsMax > 0) out.repsMax = Math.max(reps, Math.round(c.repsMax))
|
||||
@@ -958,6 +963,16 @@ function ExConfig({ ex, existing, onSave, onDelete, close, routine, initial }) {
|
||||
{mode === 'time' && !bw && <div className="small dim" style={{ marginBottom: 18 }}>
|
||||
{t('A timer runs while you hold the set. Leave the weight at 0 for bodyweight holds.')}
|
||||
</div>}
|
||||
{/* Per-exercise rest (issue #10). Its own full-width row, like the other steppers with an
|
||||
explanation under them, and outside every mode branch because a heavy triple, a plank
|
||||
and a cardio interval all rest — they just do not all want the same break. */}
|
||||
<div className="row cfgrow" style={{ marginBottom: 6 }}>
|
||||
<Stepper label={t('Rest (s)')} value={c.restSec || 0} step={15} decimal={false}
|
||||
onChange={v => setC(x => ({ ...x, restSec: v }))} />
|
||||
</div>
|
||||
<div className="small dim" style={{ marginBottom: 18 }}>
|
||||
{t('Rest after each set of this exercise. Leave at 0 to use your default rest timer.')}
|
||||
</div>
|
||||
{/* ---------- bodyweight + per side (issues #31/#32/#33) ---------- */}
|
||||
{!cardio && <div className="sect-b" style={{ marginBottom: 8 }}>
|
||||
<Row icon="figureStrength" iconTint="var(--acc)" title={t('Bodyweight')}
|
||||
|
||||
@@ -8,7 +8,7 @@ import { fmtNum, fmtDate, todayISO, exCount, DAYN } from '../lib/format.js'
|
||||
import { beep, vibrate } from '../lib/sound.js'
|
||||
import { t, exerciseNameFor } from '../lib/i18n.js'
|
||||
import { api } from '../lib/api.js'
|
||||
import { insertionIndexAfterCurrentUnit, nextUnfinishedUnit, setProgressHighWater, supersetFlowStep, restAfterSet, restOnRecheck } from '../lib/supersetFlow.js'
|
||||
import { insertionIndexAfterCurrentUnit, nextUnfinishedUnit, setProgressHighWater, supersetFlowStep, restAfterSet, restOnRecheck, restSecFor } from '../lib/supersetFlow.js'
|
||||
import Media from '../components/Media.jsx'
|
||||
import { startFlow, exercisePicker, exConfigSheet, exerciseDetailSheet, topWeightSheet, finishWorkout, workoutCompleteSheet, confirmSheet, exerciseNoteSheet, sessionNoteSheet, swapActiveWorkoutExercise } from '../sheets.jsx'
|
||||
import Icon from '../components/Icon.jsx'
|
||||
@@ -535,11 +535,15 @@ function ActiveWorkout() {
|
||||
const restBeforeWarmup = nextUnit?.some(ui =>
|
||||
fresh.entries[ui].sets.some(set => isWarmupRow(set) && !set.done),
|
||||
)
|
||||
// The rest this set has earned: the exercise's own restSec when it set one, the global
|
||||
// timer when it did not, and the longest of the group's across a superset (issue #10).
|
||||
// Resolved once here so every branch below times the same break.
|
||||
const restSec = restSecFor(fresh.entries, freshUnit || [idx], S.restSec)
|
||||
|
||||
// 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 (!restBeforeWarmup && restOnRecheck({ timerRunning: !!useUI.getState().timer, unitDone: freshUnitDone, lastUnit: freshWorkoutDone })) startRest(S.restSec, idx)
|
||||
if (!restBeforeWarmup && restOnRecheck({ timerRunning: !!useUI.getState().timer, unitDone: freshUnitDone, lastUnit: freshWorkoutDone })) startRest(restSec, idx)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -549,7 +553,7 @@ function ActiveWorkout() {
|
||||
if (freshUnitDone) stopRest()
|
||||
if (!freshUnit || freshUnit.length <= 1) {
|
||||
if (freshUnitDone && !askTop && nextUnit?.length) update(s => { if (s.active) s.active.cur = nextUnit[0] })
|
||||
if (!restBeforeWarmup && restAfterSet({ unitDone: freshUnitDone, lastUnit: freshWorkoutDone })) startRest(S.restSec, idx)
|
||||
if (!restBeforeWarmup && restAfterSet({ unitDone: freshUnitDone, lastUnit: freshWorkoutDone })) startRest(restSec, idx)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -559,11 +563,11 @@ 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] })
|
||||
if (!restBeforeWarmup) startRest(S.restSec, idx)
|
||||
if (!restBeforeWarmup) startRest(restSec, idx)
|
||||
}
|
||||
} else {
|
||||
if (step.nextIdx != null) update(s => { if (s.active) s.active.cur = step.nextIdx })
|
||||
if (step.roundDone) startRest(S.restSec, idx)
|
||||
if (step.roundDone) startRest(restSec, idx)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user