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
Follow-up to #262: Set current goes back to cards only when the list was opened for this session, and stays in the list when it is the saved view or the exercise buttons act on the current exercise
Duarte Santosbe0998c0ce7a
diff --git a/frontend/src/views/Workout.jsx b/frontend/src/views/Workout.jsxindex bb6af3df1..aac21f3ab 100644--- a/frontend/src/views/Workout.jsx+++ b/frontend/src/views/Workout.jsx@@ -754,13 +754,16 @@ function ActiveWorkout() {// List mode shows every unit at once, so the "current" exercise is chosen by tapping// "Set current" on its header instead of Prev/Next. The bottom Move/Swap/Remove actions// keep operating on it, and completing sets still advances it on its own.- // "Set current" has no purpose besides picking which exercise to look at next, so it also- // switches the session into card view (#260) rather than leaving you in the list to open- // Cards yourself - three taps for one intent otherwise.+ // When the list was only opened for this session and cards are the saved default, "Set+ // current" has no purpose besides picking which exercise to look at next, so it also goes+ // back to card view (#260) rather than leaving you in the list to open Cards yourself. It+ // stays in the list when the list is the saved default, which is a choice to keep, and when+ // the exercise buttons are on, because then the tap also picks what Move/Swap/Remove below+ // act on and the list is where you use them.const focusUnit = firstIdx => update(s => {if (!s.active) returns.active.cur = firstIdx- s.active.workoutView = 'cards'+ if (!workoutControls(s).exerciseButtons && (s.workoutView || 'cards') === 'cards') s.active.workoutView = 'cards'})// The header ⋮ re-lays-out the running session without touching the saved default// (Settings → During a workout → Workout view). It writes s.active.workoutView, which thediff --git a/frontend/src/views/Workout.test.jsx b/frontend/src/views/Workout.test.jsxindex 2e3a7deae..cf571668a 100644--- a/frontend/src/views/Workout.test.jsx+++ b/frontend/src/views/Workout.test.jsx@@ -1248,19 +1248,43 @@ describe('workout list view', () => {})it('marks the current unit and moves the mark with Set current', async () => {+ await mount([exercise('plain-bench', [false]), exercise('plain-row', [false])], 0, { workoutView: 'list' })++ await act(async () => { focusButton(units()[1]).dispatchEvent(new dom.Event('click', { bubbles: true })) })+ expect(mocks.S.active.cur).toBe(1)++ // The list is the saved default here, so the tap only moves the mark and the list stays.+ await rerender()+ expect(mocks.S.active.workoutView).toBeUndefined()+ expect(units()[0].textContent).not.toContain('Current')+ expect(units()[1].textContent).toContain('Current')+ expect(focusButton(units()[0])).toBeTruthy()+ })++ it('goes back to cards on Set current when the list was only opened for this session (#260)', async () => {await mount([exercise('plain-bench', [false]), exercise('plain-row', [false])], 0, {- workoutView: 'list', active: { workoutView: 'list' },+ workoutView: 'cards', active: { workoutView: 'list' },})await act(async () => { focusButton(units()[1]).dispatchEvent(new dom.Event('click', { bubbles: true })) })+ // Picking the exercise to look at next is all the tap is for, and cards are where one+ // exercise is front and centre, so it does not take a second trip through the ⋮ menu.expect(mocks.S.active.cur).toBe(1)-- // #260: "Set current" has no purpose besides jumping to that exercise, so it now also- // drops the session back into card view - the only place a single exercise is front and- // center - instead of leaving you in the list to tap Cards yourself.expect(mocks.S.active.workoutView).toBe('cards')})+ it('stays in the list on Set current when the exercise buttons act on the current exercise', async () => {+ await mount([exercise('plain-bench', [false]), exercise('plain-row', [false])], 0, {+ workoutView: 'cards', wc: { exerciseButtons: true }, active: { workoutView: 'list' },+ })++ await act(async () => { focusButton(units()[1]).dispatchEvent(new dom.Event('click', { bubbles: true })) })+ // Move/Swap/Remove below the list act on the exercise marked Current, so the tap picks their+ // target and jumping away to cards would take the buttons out from under the athlete.+ expect(mocks.S.active.cur).toBe(1)+ expect(mocks.S.active.workoutView).toBe('list')+ })+// Since !92 finishing an exercise no longer moves the current marker on its own (cards use// Next, the list uses "Set current"); completion still starts the rest like cards do.it('completing a set in list mode starts the rest and leaves the current marker in place, like cards do', async () => {