Workout QA: the per-side set number is a real button again, a unilateral set's volume is each side's weight × reps, timed and cardio sets from older data read as time again, finish summary tiles stay 2×2 in the dialog on desktop, exercise names in menu titles and toasts are capitalised (Kg no longer is)
This commit is contained in:
1 parent
88a1c317e5
commit
33be28b8e6
6 files changed
+38
-11
No files matched your search
@@ -674,7 +674,8 @@ body.chips-dragging *{cursor:inherit}
|
||||
.setph{margin:8px 0 2px;font-size:11px;letter-spacing:.08em;text-transform:uppercase;color:var(--dim);display:flex;align-items:center;gap:10px}
|
||||
.setph::after{content:'';flex:1;height:1px;background:var(--sep)}
|
||||
.setsep{height:1px;background:var(--sep);margin:9px 0}
|
||||
.setrow .n{
|
||||
/* the per-side wrapper carries its own .n (the set number in front of the L/R rows) */
|
||||
.setrow .n,.setrow-side>.n{
|
||||
width:24px;height:24px;border-radius:50%;background:var(--surface-2);color:var(--label-2);
|
||||
display:flex;align-items:center;justify-content:center;font-size:12px;font-weight:500;flex:none;
|
||||
position:relative;padding:0;border:0;font-family:inherit;cursor:pointer;
|
||||
@@ -1168,7 +1169,7 @@ body.chips-dragging *{cursor:inherit}
|
||||
#modal-root .list,.narrow .list{display:flex;flex-direction:column}
|
||||
.narrow{max-width:640px;margin:0 auto}
|
||||
.tiles{grid-template-columns:repeat(4,1fr)}
|
||||
.cols .tiles{grid-template-columns:1fr 1fr}
|
||||
.cols .tiles,.center .tiles{grid-template-columns:1fr 1fr} /* a 300px dialog has no room for four */
|
||||
#tabbar{
|
||||
left:50%;right:auto;bottom:16px;transform:translateX(-50%);width:520px;
|
||||
border:var(--hair) solid var(--sep-op);border-radius:var(--r-xl);
|
||||
|
||||
@@ -26,6 +26,9 @@ export function fmtDur(ms) {
|
||||
export const durPart = ms => (ms >= 60000 ? [fmtDur(ms)] : [])
|
||||
// Numbers follow the UI language, like the dates above — a hardcoded locale put Swiss
|
||||
// apostrophes ("7'535 kg") in front of every user, in every language.
|
||||
// Exercise names are stored lower-case and shown through CSS `capitalize`; text that has no
|
||||
// element of its own (a toast) capitalises here instead.
|
||||
export const capWords = s => String(s || '').replace(/(^|[\s(\-\/])(\p{Ll})/gu, (m, pre, ch) => pre + ch.toUpperCase())
|
||||
export const fmtNum = n => (Math.round(n * 10) / 10).toLocaleString(dateLocale())
|
||||
// Volume stays in the profile's unit throughout: the old shorthand turned anything over
|
||||
// 10 000 into "t", which is wrong for a pound profile and made one list mix "18.8t" with
|
||||
|
||||
@@ -107,7 +107,10 @@ const effortTail = s => {
|
||||
// entry or a workout entry); passing an id alone keeps the old body-part behaviour.
|
||||
export function setLabel(id, s, cfg) {
|
||||
const c = cfg || { id }
|
||||
const mode = modeOf(c)
|
||||
let mode = modeOf(c)
|
||||
// A set saved by an older build carries no target with it; the set's own fields still say what
|
||||
// it was — seconds for a timed set, minutes for cardio — so those are not read back as "0 reps".
|
||||
if (!cfg && !(s.r > 0)) { if (s.min > 0 || s.speed > 0) mode = 'cardio'; else if (s.sec > 0) mode = 'time' }
|
||||
if (mode === 'cardio') return `${s.min || 0} min @ ${fmtNum(s.speed || 0)} km/h`
|
||||
if (mode === 'time') return fmtSec(s.sec) + (s.w > 0 ? ` · ${fmtNum(s.w)}` : '')
|
||||
const bw = isBw({ ...c, id: c.id ?? id })
|
||||
@@ -483,8 +486,13 @@ export function workoutVolume(w) {
|
||||
// does it; this line was the one that did not, which only stopped being harmless when a
|
||||
// routine started planning warm-ups by default. The number is written into the saved
|
||||
// workout, so an inflated one would stay wrong forever.
|
||||
// A per-side row's mirror is `w = max(L, R), r = L + R` (workout-model syncSideAggregate) —
|
||||
// right for a headline, wrong for a product: 14×10 left and 12.5×6 right is 215, not 14×16.
|
||||
// Each side is its own weight × reps, with its own drops and bursts.
|
||||
w.entries.forEach(e => e.sets.forEach(s => {
|
||||
if (s.done && !isWarmupRow(s)) v += (s.w || 0) * (s.r || 0) + extraVolumeOf(s)
|
||||
if (!s.done || isWarmupRow(s)) return
|
||||
if (isSideSet(s)) { for (const side of [s.sides.L, s.sides.R]) v += (side.w || 0) * (side.r || 0) + extraVolumeOf(side); return }
|
||||
v += (s.w || 0) * (s.r || 0) + extraVolumeOf(s)
|
||||
}))
|
||||
return v
|
||||
}
|
||||
|
||||
@@ -1161,3 +1161,18 @@ describe('lastEntryFor / buildSets skip a noProg entry', () => {
|
||||
expect(bestWeightFor(S, LIFT2)).toBe(140)
|
||||
})
|
||||
})
|
||||
|
||||
describe('per-side volume and legacy timed sets (QA round 2026-09-12)', () => {
|
||||
it('sums each side of a unilateral set on its own instead of max weight × total reps', () => {
|
||||
const w = { entries: [{ id: 'x', sets: [
|
||||
{ done: true, sides: { L: { w: 14, r: 10, done: true }, R: { w: 12.5, r: 6, done: true } }, w: 14, r: 16 },
|
||||
{ done: true, w: 100, r: 10 }
|
||||
] }] }
|
||||
expect(workoutVolume(w)).toBe(14 * 10 + 12.5 * 6 + 1000)
|
||||
})
|
||||
it('reads a timed or cardio set saved without a target from the set itself', () => {
|
||||
expect(setLabel('0001', { sec: 45, done: true })).toBe('0:45')
|
||||
expect(setLabel('0001', { min: 20, speed: 8, done: true })).toBe('20 min @ 8 km/h')
|
||||
expect(setLabel('0025', { w: 60, r: 10, done: true })).toBe('60×10')
|
||||
})
|
||||
})
|
||||
@@ -3,7 +3,7 @@ import { useStore } from './store/useStore.js'
|
||||
import { useUI } from './store/useUI.js'
|
||||
import { EXDB, EXIDX, BODYPARTS, isCardio, isBodyweightEq, allExercises, equipmentOf, smOf, matchExercise, exOr } from './lib/exercises.js'
|
||||
import { activeProfile, exAvailable, ALL_EQUIPMENT, newProfile } from './lib/equipment.js'
|
||||
import { fmtDate, fmtNum, fmtVol, fmtDur, durPart, todayISO, isoOf, uid, exCount, DAYN, DAYS, weekOrder, weekStartOf, weekDayOffset, MONTHS_LONG, ACCENTS } from './lib/format.js'
|
||||
import { fmtDate, fmtNum, capWords, fmtVol, fmtDur, durPart, todayISO, isoOf, uid, exCount, DAYN, DAYS, weekOrder, weekStartOf, weekDayOffset, MONTHS_LONG, ACCENTS } from './lib/format.js'
|
||||
import { lastEntryFor, bestWeightFor, bestWeightForEntry, buildSets, effectiveRoutineIds, workoutVolume, setsDone, setsDoneActive, setUnitsTotal, lastBW, supersetUnits, unitOf, setLabel, defaultConfig, cleanupSg, modeOf, effortOf, EFFORT, capEffort, stepEffort, isBw, isPerSide, sideReps, workSetsDone, applyIntensifierPlan, MAX_PLANNED_WARMUPS, NOTE_MAX } from './lib/history.js'
|
||||
import { usesBar, barWeightFor, defaultBarWeight, hasBarOverride } from './lib/bar.js'
|
||||
import { toScale, rirOf, EFFORT_PRESETS, effortColor } from './lib/effort.js'
|
||||
@@ -61,7 +61,7 @@ function ConfirmDialog({ title, message, confirmText, cancelText, danger, onConf
|
||||
// items: [{ icon, label, sub, onClick, danger, disabled, on }] — `on` draws a check for toggles.
|
||||
function MenuSheet({ title, subtitle, items, close }) {
|
||||
return <>
|
||||
{title && <h3 style={{ marginBottom: subtitle ? 2 : 10 }}>{title}</h3>}
|
||||
{title && <h3 className="capitalize" style={{ marginBottom: subtitle ? 2 : 10 }}>{title}</h3>}
|
||||
{subtitle && <div className="muted small" style={{ marginBottom: 10 }}>{subtitle}</div>}
|
||||
<div className="list menu-list">
|
||||
{items.filter(Boolean).map((it, i) => <div key={i}
|
||||
@@ -728,7 +728,7 @@ function AddToRoutine({ ex, close }) {
|
||||
if (r) r.ex.push({ id: ex.id, ...cfg })
|
||||
})
|
||||
const r = isNew ? S().routines[S().routines.length - 1] : st.routines.find(x => x.id === rid)
|
||||
toast(t('“{0}” added to {1}', exerciseNameFor(ex), r ? r.name : t('routine')))
|
||||
toast(t('“{0}” added to {1}', capWords(exerciseNameFor(ex)), r ? r.name : t('routine')))
|
||||
if (isNew && r) nav('/plan/r/' + r.id)
|
||||
}, null, isNew ? null : st.routines.find(x => x.id === rid))
|
||||
}
|
||||
@@ -2051,8 +2051,8 @@ function FinishSummary({ w, prs, e1prs = [], close }) {
|
||||
<div className="tile"><div className="l">{t('PRs')}</div><div className="v" style={{ fontSize: 20 }}>{prs.length || '—'}</div></div>
|
||||
</div>
|
||||
{(prs.length > 0 || e1prs.length > 0) && <div style={{ textAlign: 'left', marginBottom: 12 }}>
|
||||
{prs.map(id => <div key={id} className="small accent capitalize row" style={{ gap: 5 }}><Icon name="trophy" style={{ fontSize: 13 }} />{t('New PR:')} {EXIDX[id] ? exerciseNameFor(EXIDX[id]) : id}</div>)}
|
||||
{e1prs.map(p => <div key={p.id} className="small accent capitalize row" style={{ gap: 5 }}><Icon name="chartLine" style={{ fontSize: 13 }} />{t('Best estimated 1RM:')} {EXIDX[p.id] ? exerciseNameFor(EXIDX[p.id]) : p.id} · {fmtNum(p.est)} {st.unit}</div>)}
|
||||
{prs.map(id => <div key={id} className="small accent row" style={{ gap: 5 }}><Icon name="trophy" style={{ fontSize: 13 }} />{t('New PR:')} <span className="capitalize">{EXIDX[id] ? exerciseNameFor(EXIDX[id]) : id}</span></div>)}
|
||||
{e1prs.map(p => <div key={p.id} className="small accent row" style={{ gap: 5 }}><Icon name="chartLine" style={{ fontSize: 13 }} />{t('Best estimated 1RM:')} <span className="capitalize">{EXIDX[p.id] ? exerciseNameFor(EXIDX[p.id]) : p.id}</span> · {fmtNum(p.est)} {st.unit}</div>)}
|
||||
</div>}
|
||||
<h4 className="sec" style={{ textAlign: 'left' }}>{t('What you just trained')}</h4>
|
||||
<BodyMap load={loadOfWorkouts([w])} body={st.body} />
|
||||
|
||||
@@ -6,7 +6,7 @@ import { useUI } from '../store/useUI.js'
|
||||
import { exOr } from '../lib/exercises.js'
|
||||
import { usesBar, barWeightFor, plateSplit } from '../lib/bar.js'
|
||||
import { effectiveRoutines, effectiveRoutineIds, lastEntryFor, bestWeightFor, bestWeightForEntry, buildSets, freestyleConfig, defaultConfig, setsDoneActive, setUnitsTotal, supersetUnits, unitOf, setLabel, modeOf, isBw, isPerSide, repStep, EFFORT, effortOf, stepEffort, capEffort, cascadeWeight, insertWarmupRow, removeRowAt, pairAdjacent, unpairSuperset, cleanupSg, applyIntensifierPlan, pinnedNoteFor, exNoteFor } from '../lib/history.js'
|
||||
import { fmtNum, fmtDate, todayISO, exCount, DAYN } from '../lib/format.js'
|
||||
import { fmtNum, capWords, 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'
|
||||
@@ -1039,7 +1039,7 @@ function ActiveWorkout() {
|
||||
// button. Quick-add commits with the same default (or, freestyle, last-session) config
|
||||
// the sheet would have opened with; tapping the row still opens that sheet for anyone
|
||||
// who wants to set sets/reps first.
|
||||
if (quick) { commit(seed || defaultConfig(ex.id)); useUI.getState().toast(t('“{0}” added to {1}', exerciseNameFor(ex), routine ? routine.name : t('Freestyle'))) }
|
||||
if (quick) { commit(seed || defaultConfig(ex.id)); useUI.getState().toast(t('“{0}” added to {1}', capWords(exerciseNameFor(ex)), routine ? routine.name : t('Freestyle'))) }
|
||||
else exConfigSheet(ex, null, commit, null, routine, seed)
|
||||
})} icon="plus">{t('Add exercise')}</Button>
|
||||
{wc.exerciseButtons && A.entries.length > 0 && <>
|
||||
|
||||
Reference in new issue
Block a user