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.

curated2: !45

Duarte Santos77996ec1678f
diff --cc frontend/src/views/RoutineEdit.jsx
index 147060848,88714e1a3..5a331ff70
--- a/frontend/src/views/RoutineEdit.jsx
+++ b/frontend/src/views/RoutineEdit.jsx
@@@ -26,19 -298,12 +298,21 @@@ export default function RoutineEdit()
// auto-backup on the way out (not per keystroke) covers the whole editing session, deletion
// included: this still unmounts after the delete button navigates away.
useEffect(() => () => useStore.getState().autoBackupNow(), [])
- if (!r) return null
-
const edit = fn => update(s => { fn(s.routines.find(x => x.id === id).ex) })
+ const reorder = useRoutineReorder(r, r?.ex || [], (sourceIndex, targetSlot) => {
+ edit(exercises => { reorderRoutineUnit(exercises, sourceIndex, targetSlot) })
+ })
+ if (!r) return null
- const move = (i, dir) => edit(ex => { const j = i + dir; if (j < 0 || j >= ex.length) return;[ex[i], ex[j]] = [ex[j], ex[i]]; cleanupSg(ex) })
+ const move = (i, dir) => {
+ // Guard before update so a stale/boundary activation cannot trigger persistence or cleanup.
+ if (!moveSupersetUnit(r.ex, i, dir)) return
+ edit(ex => {
+ const reordered = moveSupersetUnit(ex, i, dir)
+ if (!reordered) return
+ ex.splice(0, ex.length, ...reordered)
+ cleanupSg(ex)
+ })
+ }
const toggleLink = i => edit(ex => {
if (i < 1) return
const cur = ex[i], prev = ex[i - 1]