Custom exercises: the target muscle is the primary tapped first, not the topmost one on the map (QA C10)
Since the muscles are stored in the map's order, the one-word target `tg` was taken from the head of that sorted list, so a hip thrust or deadlift with Traps as an extra primary showed up as "Traps · barbell" in the library, the picker and the Muscles view — and because tap order was discarded, the user had no way to correct it. The list stays in map order; the target is the primary the user picked first, and editing an exercise keeps its target as long as that muscle is still a primary. Rig check on the branch build (slot 71, 368 px, Hamstrings → Glutes → Traps): stored primaries ['trapezius','gluteal','hamstring'], tg 'hamstring'; library row, picker row and Muscles > Glutes / Hamstrings all read "Hamstrings · barbell".
This commit is contained in:
1 parent
83b2a140d6
commit
cc116bdbcc
2 files changed
+119
-2
No files matched your search
@@ -795,13 +795,17 @@ function CustomExForm({ existing, prefill, onDone, close }) {
|
||||
const prim = bp === 'cardio' ? ['cardiovascular system'] : inMuscleOrder(primaries)
|
||||
const sm = inMuscleOrder(secondaries.filter(m => !prim.includes(m)))
|
||||
const groups = [...prim, ...sm]
|
||||
// The one-word target (the library row, the picker, the Muscles view) is not the sorted list's
|
||||
// head — a hip thrust with Traps as an extra primary is not a Traps exercise. It is the primary
|
||||
// tapped first, and an edit keeps the exercise's target as long as that muscle is still a primary.
|
||||
const tg = (existing && prim.includes(existing.tg)) ? existing.tg : (primaries.find(m => prim.includes(m)) || prim[0] || '')
|
||||
let id = existing && existing.id
|
||||
if (existing) update(s => { const c = (s.customEx || []).find(x => x.id === id); if (c) {
|
||||
c.n = name; c.bp = bp; c.desc = d; c.tg = prim[0] || ''; c.sm = sm; c.muscleGroups = groups; c.primaries = prim; c.secondaries = sm; c.eq = eq
|
||||
c.n = name; c.bp = bp; c.desc = d; c.tg = tg; c.sm = sm; c.muscleGroups = groups; c.primaries = prim; c.secondaries = sm; c.eq = eq
|
||||
} })
|
||||
else {
|
||||
id = 'c' + uid()
|
||||
update(s => { (s.customEx = s.customEx || []).push({ id, n: name, bp, desc: d, tg: prim[0] || '', sm, muscleGroups: groups, primaries: prim, secondaries: sm, eq, custom: true }) })
|
||||
update(s => { (s.customEx = s.customEx || []).push({ id, n: name, bp, desc: d, tg, sm, muscleGroups: groups, primaries: prim, secondaries: sm, eq, custom: true }) })
|
||||
}
|
||||
close()
|
||||
toast(existing ? t('Saved') : t('“{0}” created', name))
|
||||
|
||||
Reference in new issue
Block a user