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
settings: show the version, and let the rest timer be turned off
Duarte Santos9bec4bb785bd
diff --git a/frontend/src/store/useUI.js b/frontend/src/store/useUI.jsindex d1a121a79..53d292880 100644--- a/frontend/src/store/useUI.js+++ b/frontend/src/store/useUI.js@@ -76,6 +76,9 @@ export const useUI = create((set, get) => ({startRest(sec) {get().stopRest()+ // Rest timer set to Off. Stopping and returning rather than starting a zero-length timer+ // keeps every caller honest: the four places that start a rest do not each need to know.+ if (!(sec > 0)) returnconst endsAt = Date.now() + sec * 1000set({ timer: { left: sec, total: sec, endsAt } })requestRestNotificationPermission()diff --git a/frontend/src/store/useUI.test.js b/frontend/src/store/useUI.test.jsnew file mode 100644index 000000000..32c9a1c57--- /dev/null+++ b/frontend/src/store/useUI.test.js@@ -0,0 +1,28 @@+// @vitest-environment happy-dom+// useUI pulls in api.js, which reads navigator.userAgent at module scope.+import { describe, expect, it, beforeEach, afterEach, vi } from 'vitest'+import { useUI } from './useUI.js'++// "Off" has to hold at the timer itself, not at the four places that start one — the same+// reason the rest-after-a-set rule is a shared condition rather than four copies.+describe('rest timer set to Off', () => {+ beforeEach(() => { vi.useFakeTimers(); useUI.setState({ timer: null }) })+ afterEach(() => { useUI.getState().stopRest(); vi.useRealTimers() })++ it('starts nothing', () => {+ useUI.getState().startRest(0)+ expect(useUI.getState().timer).toBe(null)+ })++ it('stops a rest that is already running', () => {+ useUI.getState().startRest(90)+ expect(useUI.getState().timer).not.toBe(null)+ useUI.getState().startRest(0)+ expect(useUI.getState().timer).toBe(null)+ })++ it('still runs for a real duration', () => {+ useUI.getState().startRest(90)+ expect(useUI.getState().timer.total).toBe(90)+ })+})diff --git a/frontend/src/views/Settings.jsx b/frontend/src/views/Settings.jsxindex eb2d05367..2f4c0a4c4 100644--- a/frontend/src/views/Settings.jsx+++ b/frontend/src/views/Settings.jsx@@ -131,7 +131,7 @@ export default function Settings() {<Section title={t('During a workout')} footer={wakeOK ? t('The screen stays on while a workout is running, so you don’t have to unlock your phone between sets.') : null}><SelectRow icon="timer" iconTint="var(--orange)" title={t('Rest timer')}value={S.restSec} onChange={v => update(s => { s.restSec = v })}- options={[60, 90, 120, 150, 180].map(v => ({ value: v, label: v + 's' }))} />+ options={[{ value: 0, label: t('Off') }, ...[60, 90, 120, 150, 180].map(v => ({ value: v, label: v + 's' }))]} />{/* Default for a rest-pause burst added live on a plain set — a planned exercise's own"Rest (s)" (in its Intensifier config) overrides this, same as the main rest timeris the fallback whenever an exercise has no progression rule of its own. */}@@ -223,8 +223,12 @@ export default function Settings() {subtitle={t('to install openGym as a full-screen app.') + ' ' + (user ? t('Your data syncs with your profile — sign in anywhere to see it.') : t('Guest data stays on this device — export a backup now and then!'))} /></Section>}+ {/* The version, at the bottom of Settings — which is where the support template has been+ telling people to look for it, and where it was not. On the phone build there is no+ address bar and no about box, so without this there is no way to tell which build you+ are running, or whether an update actually installed. */}<div className="dim small" style={{ textAlign: 'center', marginTop: 4, lineHeight: 1.6 }}>- openGym · {t('free & open source (AGPL v3)')}<br />+ openGym v{__APP_VERSION__} · {t('free & open source (AGPL v3)')}<br /><a href="https://gitlab.com/DuarteSantos8/opengym" target="_blank" rel="noopener">source code</a> · exercise data: hasaneyldrm/exercises-dataset (MIT)<br />exercise images and animations © <a href="https://gymvisual.com/" target="_blank" rel="noopener">Gym visual</a></div>diff --git a/frontend/vite.config.js b/frontend/vite.config.jsindex bda3efa75..88905d81c 100644--- a/frontend/vite.config.js+++ b/frontend/vite.config.js@@ -1,3 +1,4 @@+import { readFileSync } from 'node:fs'import { defineConfig } from 'vite'import react from '@vitejs/plugin-react'@@ -28,7 +29,13 @@ const umami = {}}+// The version people are asked for in #install-help and on every bug report. Read from+// package.json so it cannot drift from the release it was built in, and inlined at build+// time so no runtime fetch is involved.+const pkgVersion = JSON.parse(readFileSync(new URL('./package.json', import.meta.url), 'utf8')).version+export default defineConfig({+ define: { __APP_VERSION__: JSON.stringify(pkgVersion) },plugins: [react(), umami],base: './',server: {