Skip to content

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.

Fix rest timer freezing at 0:01 (#14)

Duarte Santos33317dac914c
diff --git a/frontend/src/store/useUI.js b/frontend/src/store/useUI.js
index b9529314a..4df1d0e11 100644
--- a/frontend/src/store/useUI.js
+++ b/frontend/src/store/useUI.js
@@ -40,26 +40,26 @@ export const useUI = create((set, get) => ({
set({ timer: { left: sec, total: sec, endsAt } })
pushRestTimer(sec)
timerTick = () => {
- const t = get().timer
- if (!t) return
- const left = Math.max(0, Math.round((t.endsAt - Date.now()) / 1000))
- if (left === t.left) return
+ const tm = get().timer
+ if (!tm) return
+ const left = Math.max(0, Math.round((tm.endsAt - Date.now()) / 1000))
+ if (left === tm.left) return
const snd = useStore.getState().S.sound
if (left <= 0) {
beep(snd, 880, 0.15); beep(snd, 880, 0.15, 0.25); beep(snd, 1320, 0.4, 0.5)
vibrate([200, 100, 200]); get().toast(t('Rest over — next set! 💪')); get().stopRest(); return
}
if (left <= 3) beep(snd, 660, 0.1)
- set({ timer: { ...t, left } })
+ set({ timer: { ...tm, left } })
}
timerInt = setInterval(timerTick, 1000)
document.addEventListener('visibilitychange', timerTick)
},
addRest(sec) {
- const t = get().timer
- if (!t) return
- const left = t.left + sec
- set({ timer: { ...t, left, total: t.total + sec, endsAt: t.endsAt + sec * 1000 } })
+ const tm = get().timer
+ if (!tm) return
+ const left = tm.left + sec
+ set({ timer: { ...tm, left, total: tm.total + sec, endsAt: tm.endsAt + sec * 1000 } })
pushRestTimer(left)
},
stopRest() {