Open-source gym & body-weight tracker, now in the App Store (iPhone + Apple Watch) and as an Android APK. Plan routines, log workouts, see which muscles are trained, import from Strong/Hevy/FitNotes. Self-host it or use it on the phone alone.
JavaScript apple-watchbodyweightdockerfitnessfitness-trackergymhealthiosmcpnodejspasskeysprogressive-web-applicationspwareactself-hostedself-hostingvitewebauthnweightliftingworkout-tracker
Workout: editing a past workout no longer shows its own pinned note twice
Duarte Santos8f0f21149cbf
diff --git a/frontend/src/lib/history.js b/frontend/src/lib/history.jsindex 21b285250..b3587b643 100644--- a/frontend/src/lib/history.js+++ b/frontend/src/lib/history.js@@ -367,8 +367,14 @@ export const NOTE_MAX = 500*/export function pinnedNoteFor(S, exId) {const workouts = S?.workouts || []+ // Editing a logged workout: its own pinned note is already in the editor, as that entry's+ // note, so it is not shown a second time as the note from last time. The key is the one+ // session-edit.js gives the editor (id, or day|start for a workout logged before ids).+ const editing = S?.active?.editingWorkoutIdfor (let i = workouts.length - 1; i >= 0; i--) {- const en = (workouts[i].entries || []).find(e => e.id === exId)+ const w = workouts[i]+ if (editing != null && (w.id != null ? w.id : `${w.d}|${w.start}`) === editing) continue+ const en = (w.entries || []).find(e => e.id === exId)const note = (en?.note || '').trim()if (note && en.notePin) return { note, d: workouts[i].d }}diff --git a/frontend/src/lib/history.test.js b/frontend/src/lib/history.test.jsindex 179682898..b3f43aeac 100644--- a/frontend/src/lib/history.test.js+++ b/frontend/src/lib/history.test.js@@ -1161,6 +1161,18 @@ describe('pinnedNoteFor', () => {expect(pinnedNoteFor({ workouts: [{ d: '2026-08-08', entries: [{ id: '0025', note: 'diary' }] }] }, '0025')).toBeNull()})+ it('skips the workout being edited, whose note the editor already shows', () => {+ const ws = [+ { id: 'w1', d: '2026-08-01', entries: [{ id: '0025', note: 'older pin', notePin: true }] },+ { id: 'w2', d: '2026-08-15', entries: [{ id: '0025', note: 'its own pin', notePin: true }] },+ ]+ expect(pinnedNoteFor({ workouts: ws, active: { editingWorkoutId: 'w2' } }, '0025')).toEqual({ note: 'older pin', d: '2026-08-01' })+ expect(pinnedNoteFor({ workouts: ws, active: { editingWorkoutId: 'w1' } }, '0025')).toEqual({ note: 'its own pin', d: '2026-08-15' })+ // a workout logged before ids is keyed by day and start+ const legacy = [{ d: '2026-08-15', start: 1000, entries: [{ id: '0025', note: 'its own pin', notePin: true }] }]+ expect(pinnedNoteFor({ workouts: legacy, active: { editingWorkoutId: '2026-08-15|1000' } }, '0025')).toBeNull()+ })+it('is null for an exercise with no notes, and safe on empty state', () => {expect(pinnedNoteFor(S, '9999')).toBeNull()expect(pinnedNoteFor({}, '0025')).toBeNull()