Custom exercises: create your own with name + body part
Users can add movements missing from the catalogue (issue #11) from the exercise picker or the Exercises tab. Custom exercises live in synced state (S.customEx) and are merged into the exercise index, so routines, supersets, logging, PRs, stats and history all work unchanged. The animation stays blank by design. Editable and deletable from the detail sheet; deleting keeps logged history readable by stamping the name into past entries. Translated into all 12 UI languages. Closes #11
This commit is contained in:
1 parent
93bd4e3850
commit
0cefcb3636
21 files changed
+355
-34
No files matched your search
@@ -5,6 +5,17 @@ export const EXIDX = {}
|
||||
EXDB.forEach(e => { EXIDX[e.id] = e })
|
||||
export const BODYPARTS = [...new Set(EXDB.map(e => e.bp))].sort()
|
||||
|
||||
// Custom (user-created) exercises live in synced state S.customEx (issue #11) and are
|
||||
// merged into the id index here so every EXIDX[id] lookup keeps working unchanged.
|
||||
let customIds = []
|
||||
export function registerCustom(list) {
|
||||
customIds.forEach(id => delete EXIDX[id])
|
||||
customIds = (list || []).map(e => e.id)
|
||||
;(list || []).forEach(e => { EXIDX[e.id] = e })
|
||||
}
|
||||
// Full searchable catalogue — customs first so your own exercises are easy to find.
|
||||
export const allExercises = st => [...(st.customEx || []), ...EXDB]
|
||||
|
||||
export const imgSrc = ex => 'img/' + ex.img
|
||||
export const gifSrc = ex => 'gif/' + ex.gif
|
||||
|
||||
|
||||
@@ -11,6 +11,12 @@ export function setLabel(id, s) {
|
||||
export function defaultConfig(id) {
|
||||
return isCardio(id) ? { sets: 1, min: 20, speed: 8 } : { sets: 3, reps: 10, weight: 0 }
|
||||
}
|
||||
// Drop superset ids that no longer have an adjacent partner (after unlink/reorder/remove).
|
||||
export function cleanupSg(ex) {
|
||||
ex.forEach((e, i) => {
|
||||
if (e.sg && !(ex[i - 1]?.sg === e.sg || ex[i + 1]?.sg === e.sg)) delete e.sg
|
||||
})
|
||||
}
|
||||
|
||||
export function lastEntryFor(S, exId) {
|
||||
for (let i = S.workouts.length - 1; i >= 0; i--) {
|
||||
|
||||
Reference in new issue
Block a user