Repository navigation
Can the training plan for that day be completed in one go instead of checking each item one by one? #1110
Unanswered
SerendipityZero
asked this question in
Q&A
Replies: 1 comment
|
Looking at If you want to add that logic cleanly (or wire up a "Complete All" / "Complete Exercise" button) while staying compatible with import { isSideSet } from './workout-model.js'
function markSetDone(set, now) {
if (!set) return set
if (isSideSet(set)) {
return {
...set,
done: true,
at: set.at ?? now,
sides: {
L: { ...set.sides.L, done: true },
R: { ...set.sides.R, done: true },
},
}
}
return {
...set,
done: true,
at: set.at ?? now,
// For timed holds, preserve planSec if sec isn't set yet
...(set.planSec != null && set.sec == null ? { sec: set.planSec } : {}),
}
}
// Complete a single exercise (pass entryId) or the entire active workout (omit entryId)
export function completeAllInActiveWorkout(active, { entryId = null, now = Date.now() } = {}) {
if (!active?.entries) return active
return {
...active,
entries: active.entries.map(entry => {
if (entryId && entry.id !== entryId) return entry
return {
...entry,
sets: (entry.sets || []).map(set => markSetDone(set, now)),
}
}),
}
}Why the
|
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Usually, I am in the habit of marking a check mark for my training after each session. I don't mark it while practicing. Therefore, I need to be able to complete one action or all actions with a single click. Could you provide such a running logic?
All reactions