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
Weigh in before workouts starts off for new profiles; existing ones keep theirs
Duarte Santosdbcfac4d8e49
diff --git a/frontend/src/store/useStore.js b/frontend/src/store/useStore.jsindex 9c4bc4477..0c99ea057 100644--- a/frontend/src/store/useStore.js+++ b/frontend/src/store/useStore.js@@ -160,8 +160,10 @@ export const DEF = {// Defaults on; an older profile without the key reads as on (`!== false`).showWeightCard: true,// Whether Start opens the quick weigh-in first (sheets.jsx startFlow, issue #137). Off starts- // the session straight away; weight can still be logged from Home/Stats. Defaults on; an- // older profile without the key reads as on (`!== false`).+ // the session straight away; weight can still be logged from Home/Stats. On here, so an+ // older profile without the key reads as on (`!== false`) and keeps the step it had; a profile+ // started from nothing begins with it off (freshState below, v1.3.11): most people weigh in at+ // home in the morning, not at the gym, and the step cost a tap every workout.weighIn: true,// The connection banner at the top (components/SyncBanner.jsx, #369/#330). Off hides it; a// stuck sync then shows as a dot on Home instead. Defaults on; an older profile without the@@ -214,6 +216,7 @@ export function freshState() {const s = clone(DEF)s.lang = detectedLang()s.langAuto = true+ s.weighIn = falsereturn s}diff --git a/frontend/src/store/useStore.weighin-default.test.jsx b/frontend/src/store/useStore.weighin-default.test.jsxnew file mode 100644index 000000000..188162493--- /dev/null+++ b/frontend/src/store/useStore.weighin-default.test.jsx@@ -0,0 +1,25 @@+// @vitest-environment happy-dom+// v1.3.11: "Weigh in before workouts" starts off for a profile created from nothing. A profile+// that already exists keeps what it had: one saved with the switch on stays on, and one saved+// before the setting existed (no key) still reads as on through DEF and `!== false`.+import { describe, expect, it, vi } from 'vitest'++vi.mock('../lib/api.js', () => ({ api: vi.fn() }))+vi.mock('./useUI.js', () => ({ useUI: { getState: () => ({ toast: vi.fn() }) } }))++import { freshState, DEF, restoredStateFor } from './useStore.js'++describe('weigh-in default', () => {+ it('a fresh profile starts with the weigh-in off', () => {+ expect(freshState().weighIn).toBe(false)+ })++ it('DEF keeps it on, so an existing profile without the key is not changed under it', () => {+ expect(DEF.weighIn).toBe(true)+ const old = { workouts: [{ id: 'w1' }], routines: [] } // written before the setting existed+ const S = restoredStateFor({ workouts: [], routines: [], bodyweight: [], customEx: [] }, old)+ expect(S.weighIn).toBe(true)+ const off = restoredStateFor({ workouts: [], routines: [], bodyweight: [], customEx: [] }, { ...old, weighIn: false })+ expect(off.weighIn).toBe(false)+ })+})