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 !140: a stored template id that is not a template opens the default
Duarte Santos69ed51a9a36d
diff --git a/frontend/src/views/StructuralBalance.jsx b/frontend/src/views/StructuralBalance.jsxindex a428881a1..a7de7ea63 100644--- a/frontend/src/views/StructuralBalance.jsx+++ b/frontend/src/views/StructuralBalance.jsx@@ -25,7 +25,9 @@ export default function StructuralBalance() {const nav = useNavigate()const S = useStore(s => s.S)const update = useStore(s => s.update)- const templateId = TEMPLATES[S.balanceTemplate] ? S.balanceTemplate : DEFAULT_TEMPLATE_ID+ // Own keys only: a synced or imported id such as "constructor" would otherwise find an+ // Object.prototype member and take the screen down.+ const templateId = Object.prototype.hasOwnProperty.call(TEMPLATES, S.balanceTemplate) ? S.balanceTemplate : DEFAULT_TEMPLATE_IDconst template = TEMPLATES[templateId]const results = useMemo(() => computeBalance(S, template), [S, template])diff --git a/frontend/src/views/StructuralBalance.test.jsx b/frontend/src/views/StructuralBalance.test.jsxindex 034a6241e..b87b3944b 100644--- a/frontend/src/views/StructuralBalance.test.jsx+++ b/frontend/src/views/StructuralBalance.test.jsx@@ -87,6 +87,17 @@ describe('StructuralBalance view', () => {}})+ it('falls back to the default template for a stored id that is not one, prototype names included', () => {+ for (const id of ['constructor', 'toString', '__proto__', 'hasOwnProperty', 'gone', 7, null]) {+ useStore.setState({ S: { ...useStore.getState().S, balanceTemplate: id } })+ const host = render()+ expect(host.querySelectorAll('[data-role-id]').length, String(id)).toBe(9)+ expect(host.querySelector('.seg button[aria-pressed="true"]').textContent).toBe('Poliquin')+ act(() => { mounted.splice(0).forEach(root => root.unmount()) })+ document.body.innerHTML = ''+ }+ })+it('the back chevron navigates to /stats', () => {const host = render()act(() => host.querySelector('.iconbtn').click())