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.

removed buggy reorder feature

Sebastian G3685e279a6f8
diff --git a/frontend/src/index.css b/frontend/src/index.css
index 140da1b24..5168b6161 100644
--- a/frontend/src/index.css
+++ b/frontend/src/index.css
@@ -1168,10 +1168,11 @@ h4.sec{
.ci-card-btn{width:30px;height:30px;font-size:14px;flex:none}
.ci-card .ci-label{flex:1;min-width:0;font-size:19px;font-weight:600;letter-spacing:-.014em;text-align:center;overflow-wrap:anywhere}
.ci-card .ci-value{font-size:14px;color:var(--label-2);word-break:break-all;text-align:center;font-variant-numeric:tabular-nums}
-/* long-press reorder: the lifted card floats above the rest, which dim slightly to recede. */
-.ci-rail.is-reordering{scroll-snap-type:none}
-.ci-rail.is-reordering .ci-card:not(.is-dragging){opacity:.6}
-.ci-card.is-dragging{transform:scale(1.03);box-shadow:0 12px 30px -8px rgba(0,0,0,.4);z-index:2}
+/* reorder row under a card (only shown with >1 card): ◀ position ▶ to nudge the card one slot
+ along the rail. A plain, reliable control — no drag gesture to fight the horizontal scroll. */
+.ci-reorder{display:flex;align-items:center;justify-content:center;gap:14px;margin-top:2px}
+.ci-reorder .ci-pos{font-size:13px;color:var(--label-2);font-variant-numeric:tabular-nums;min-width:44px;text-align:center}
+.ci-reorder .iconbtn:disabled{opacity:.3;pointer-events:none}
/* The QR itself: lean-qr paints 1 module per pixel, so scale it up with the browser's
nearest-neighbour so every module stays a crisp square instead of a blurred blob. White
quiet-zone padding is baked in by the renderer; the plate underneath just frames it. */
diff --git a/frontend/src/lib/pt-br-locale.test.js b/frontend/src/lib/pt-br-locale.test.js
index aa131ee90..6517939fa 100644
--- a/frontend/src/lib/pt-br-locale.test.js
+++ b/frontend/src/lib/pt-br-locale.test.js
@@ -28,10 +28,10 @@ describe('Brazilian Portuguese locale', () => {
const fingerprint = createHash('sha256').update(JSON.stringify(inherited)).digest('hex')
expect(Object.keys(PT_BR_OVERRIDES)).toHaveLength(631)
- expect(inherited).toHaveLength(615)
+ expect(inherited).toHaveLength(617)
// If this fails, review the changed keys and wording before accepting a new hash. From
// frontend/: node scripts/pt-br-inheritance-fingerprint.mjs --list
- expect(fingerprint, 'pt-PT inheritance changed; review the inherited pt-BR wording').toBe('8aa678164e6e66010767af67175b1be48139334f54cdd07b75c3f28866a48f57')
+ expect(fingerprint, 'pt-PT inheritance changed; review the inherited pt-BR wording').toBe('6a9e0df18bdd7020d2ad84104a020f2728f68b629933235fae7741b4ec71226d')
})
test('does not leak European Portuguese UI terms', () => {
diff --git a/frontend/src/locales/de.js b/frontend/src/locales/de.js
index 92b60cf97..5e206ae99 100644
--- a/frontend/src/locales/de.js
+++ b/frontend/src/locales/de.js
@@ -1158,6 +1158,8 @@ export default {
'Membership number or code': 'Mitgliedsnummer oder Code',
'Save card': 'Karte speichern',
'Gym card': 'Studio-Karte',
+ 'Move left': 'Nach links',
+ 'Move right': 'Nach rechts',
'Edit card': 'Karte bearbeiten',
'Re-scan': 'Neu scannen',
'Scan it with the camera or import a photo.': 'Scanne sie mit der Kamera oder importiere ein Foto.',
diff --git a/frontend/src/locales/es.js b/frontend/src/locales/es.js
index be1eb3790..6b14d47f8 100644
--- a/frontend/src/locales/es.js
+++ b/frontend/src/locales/es.js
@@ -1139,6 +1139,8 @@ export default {
'Membership number or code': 'Número de socio o código',
'Save card': 'Guardar tarjeta',
'Gym card': 'Tarjeta del gimnasio',
+ 'Move left': 'Mover a la izquierda',
+ 'Move right': 'Mover a la derecha',
'Edit card': 'Editar tarjeta',
'Re-scan': 'Volver a escanear',
'Scan it with the camera or import a photo.': 'Escanéala con la cámara o importa una foto.',
diff --git a/frontend/src/locales/fr.js b/frontend/src/locales/fr.js
index 704d0d194..f3b37a489 100644
--- a/frontend/src/locales/fr.js
+++ b/frontend/src/locales/fr.js
@@ -1139,6 +1139,8 @@ export default {
'Membership number or code': 'Numéro de membre ou code',
'Save card': 'Enregistrer la carte',
'Gym card': 'Carte de salle',
+ 'Move left': 'Déplacer à gauche',
+ 'Move right': 'Déplacer à droite',
'Edit card': 'Modifier la carte',
'Re-scan': 'Rescanner',
'Scan it with the camera or import a photo.': 'Scanne-la avec l’appareil photo ou importe une photo.',
diff --git a/frontend/src/locales/hi.js b/frontend/src/locales/hi.js
index 923066c34..936f19a8c 100644
--- a/frontend/src/locales/hi.js
+++ b/frontend/src/locales/hi.js
@@ -1139,6 +1139,8 @@ export default {
'Membership number or code': 'मेंबरशिप नंबर या कोड',
'Save card': 'कार्ड सहेजें',
'Gym card': 'जिम कार्ड',
+ 'Move left': 'बाएँ ले जाएँ',
+ 'Move right': 'दाएँ ले जाएँ',
'Edit card': 'कार्ड संपादित करें',
'Re-scan': 'फिर से स्कैन करें',
'Scan it with the camera or import a photo.': 'इसे कैमरे से स्कैन करें या फ़ोटो इम्पोर्ट करें।',
diff --git a/frontend/src/locales/hu.js b/frontend/src/locales/hu.js
index da6702b85..4deed2917 100644
--- a/frontend/src/locales/hu.js
+++ b/frontend/src/locales/hu.js
@@ -807,6 +807,8 @@ export default {
'Membership number or code': 'Tagsági szám vagy kód',
'Save card': 'Kártya mentése',
'Gym card': 'Terembérlet',
+ 'Move left': 'Balra',
+ 'Move right': 'Jobbra',
'Edit card': 'Kártya szerkesztése',
'Re-scan': 'Újraolvasás',
'Scan it with the camera or import a photo.': 'Olvasd be a kamerával, vagy importálj egy fotót.',
diff --git a/frontend/src/locales/it.js b/frontend/src/locales/it.js
index 3a98e9f05..64cf97ac0 100644
--- a/frontend/src/locales/it.js
+++ b/frontend/src/locales/it.js
@@ -1139,6 +1139,8 @@ export default {
'Membership number or code': 'Numero tessera o codice',
'Save card': 'Salva tessera',
'Gym card': 'Tessera palestra',
+ 'Move left': 'Sposta a sinistra',
+ 'Move right': 'Sposta a destra',
'Edit card': 'Modifica tessera',
'Re-scan': 'Scansiona di nuovo',
'Scan it with the camera or import a photo.': 'Scansionala con la fotocamera o importa una foto.',
diff --git a/frontend/src/locales/ko.js b/frontend/src/locales/ko.js
index c411344f4..2bc5b8f5a 100644
--- a/frontend/src/locales/ko.js
+++ b/frontend/src/locales/ko.js
@@ -1139,6 +1139,8 @@ export default {
'Membership number or code': '회원 번호 또는 코드',
'Save card': '카드 저장',
'Gym card': '헬스장 카드',
+ 'Move left': '왼쪽으로 이동',
+ 'Move right': '오른쪽으로 이동',
'Edit card': '카드 편집',
'Re-scan': '다시 스캔',
'Scan it with the camera or import a photo.': '카메라로 스캔하거나 사진을 가져오세요.',
diff --git a/frontend/src/locales/pl.js b/frontend/src/locales/pl.js
index 195fed8ac..c20cfaabf 100644
--- a/frontend/src/locales/pl.js
+++ b/frontend/src/locales/pl.js
@@ -1139,6 +1139,8 @@ export default {
'Membership number or code': 'Numer członkowski lub kod',
'Save card': 'Zapisz kartę',
'Gym card': 'Karta siłowni',
+ 'Move left': 'Przesuń w lewo',
+ 'Move right': 'Przesuń w prawo',
'Edit card': 'Edytuj kartę',
'Re-scan': 'Zeskanuj ponownie',
'Scan it with the camera or import a photo.': 'Zeskanuj ją aparatem lub zaimportuj zdjęcie.',
diff --git a/frontend/src/locales/pt.js b/frontend/src/locales/pt.js
index a1eead5b3..60c8cd1cb 100644
--- a/frontend/src/locales/pt.js
+++ b/frontend/src/locales/pt.js
@@ -1139,6 +1139,8 @@ export default {
'Membership number or code': 'Número de sócio ou código',
'Save card': 'Guardar cartão',
'Gym card': 'Cartão do ginásio',
+ 'Move left': 'Mover para a esquerda',
+ 'Move right': 'Mover para a direita',
'Edit card': 'Editar cartão',
'Re-scan': 'Digitalizar de novo',
'Scan it with the camera or import a photo.': 'Digitaliza-o com a câmara ou importa uma foto.',
diff --git a/frontend/src/locales/ru.js b/frontend/src/locales/ru.js
index db18d512e..cafbfc871 100644
--- a/frontend/src/locales/ru.js
+++ b/frontend/src/locales/ru.js
@@ -1139,6 +1139,8 @@ export default {
'Membership number or code': 'Номер участника или код',
'Save card': 'Сохранить карту',
'Gym card': 'Карта зала',
+ 'Move left': 'Влево',
+ 'Move right': 'Вправо',
'Edit card': 'Изменить карту',
'Re-scan': 'Сканировать заново',
'Scan it with the camera or import a photo.': 'Отсканируйте её камерой или импортируйте фото.',
diff --git a/frontend/src/locales/th.js b/frontend/src/locales/th.js
index a64775838..9061748af 100644
--- a/frontend/src/locales/th.js
+++ b/frontend/src/locales/th.js
@@ -815,6 +815,8 @@ export default {
'Membership number or code': 'หมายเลขสมาชิกหรือรหัส',
'Save card': 'บันทึกบัตร',
'Gym card': 'บัตรยิม',
+ 'Move left': 'ย้ายไปทางซ้าย',
+ 'Move right': 'ย้ายไปทางขวา',
'Edit card': 'แก้ไขบัตร',
'Re-scan': 'สแกนใหม่',
'Scan it with the camera or import a photo.': 'สแกนด้วยกล้องหรือนำเข้ารูปถ่าย',
diff --git a/frontend/src/locales/tr.js b/frontend/src/locales/tr.js
index b3318eadd..d51bbca38 100644
--- a/frontend/src/locales/tr.js
+++ b/frontend/src/locales/tr.js
@@ -1139,6 +1139,8 @@ export default {
'Membership number or code': 'Üyelik numarası veya kodu',
'Save card': 'Kartı kaydet',
'Gym card': 'Salon kartı',
+ 'Move left': 'Sola taşı',
+ 'Move right': 'Sağa taşı',
'Edit card': 'Kartı düzenle',
'Re-scan': 'Yeniden tara',
'Scan it with the camera or import a photo.': 'Kamerayla tara ya da bir fotoğraf içe aktar.',
diff --git a/frontend/src/locales/zh.js b/frontend/src/locales/zh.js
index a489deed8..053d4976e 100644
--- a/frontend/src/locales/zh.js
+++ b/frontend/src/locales/zh.js
@@ -1139,6 +1139,8 @@ export default {
'Membership number or code': '会员号或代码',
'Save card': '保存卡片',
'Gym card': '健身房卡片',
+ 'Move left': '向左移动',
+ 'Move right': '向右移动',
'Edit card': '编辑卡片',
'Re-scan': '重新扫描',
'Scan it with the camera or import a photo.': '用相机扫描或导入照片。',
diff --git a/frontend/src/views/CheckIn.jsx b/frontend/src/views/CheckIn.jsx
index b62f253bf..546b293fa 100644
--- a/frontend/src/views/CheckIn.jsx
+++ b/frontend/src/views/CheckIn.jsx
@@ -1,4 +1,4 @@
-import { useEffect, useLayoutEffect, useRef, useState } from 'react'
+import { useLayoutEffect, useRef, useState } from 'react'
import { useNavigate } from 'react-router-dom'
import { useStore } from '../store/useStore.js'
import { useUI } from '../store/useUI.js'
@@ -13,16 +13,9 @@ import CameraScan from '../components/CameraScan.jsx'
import { Button, TextField } from '../components/ui.jsx'
import { confirmSheet } from '../sheets.jsx'
-// Long-press before a card lifts for reordering, and the finger travel that instead counts as a
-// horizontal swipe of the rail. Mirrors the routine-editor drag (views/RoutineEdit.jsx) so the
-// gesture feels the same across the app.
-export const CI_LONG_PRESS_MS = 380
-export const CI_DRAG_SLOP = 8
-
// Move the card at `from` to sit at index `to`, returning a new array (the input is left alone).
-// This is the whole of the reorder once the drop target is known — kept as a pure function, apart
-// from the pointer maths that computes `to`, so the ordering contract can be tested without a DOM.
-// Out-of-range or no-op moves return an unchanged copy rather than throwing.
+// Backs the on-card ◀ ▶ reorder buttons. Out-of-range or no-op moves return an unchanged copy
+// rather than throwing, so a button at either end is simply inert.
export function moveGymCard(cards, from, to) {
const next = [...cards]
if (from < 0 || from >= next.length) return next
@@ -41,8 +34,8 @@ export function moveGymCard(cards, from, to) {
// The rail reopens on the card you used last (lastGymCardId) and remembers the one you settle on,
// so a member with two gyms lands on the right code without swiping. Cards are added by scanning
// or importing a photo only — never by typing a code, which is too easy to fat-finger into a
-// code that silently fails at the turnstile. An existing card can be edited (rename, re-scan) and
-// the whole rail can be reordered with a long-press drag.
+// code that silently fails at the turnstile. An existing card can be edited (rename, re-scan), and
+// with more than one card each carries ◀ ▶ buttons to nudge its position along the rail.
export default function CheckIn() {
const nav = useNavigate()
const cards = useStore(s => s.S.gymCards) || []
@@ -50,7 +43,6 @@ export default function CheckIn() {
const update = useStore(s => s.update)
const railRef = useRef(null)
const [active, setActive] = useState(0)
- const reorder = useRailReorder(railRef, cards)
// Open on the last-used card. Done once on mount (and whenever the saved id changes from
// elsewhere) with layout effect so the jump happens before paint — no visible scroll from 0.
@@ -85,13 +77,14 @@ export default function CheckIn() {
</div>
</div>
- <div className={'ci-rail' + (reorder.dragging ? ' is-reordering' : '')} ref={railRef} onScroll={onScroll}>
- {cards.map(card => <CardFace
+ <div className="ci-rail" ref={railRef} onScroll={onScroll}>
+ {cards.map((card, i) => <CardFace
key={card.id}
card={card}
- dragging={reorder.dragId === card.id}
+ index={i}
+ count={cards.length}
/>)}
- <button className="ci-add" onClick={openAddCard} data-nodrag>
+ <button className="ci-add" onClick={openAddCard}>
<Icon name="plus" />
<span className="ci-add-t">{t('Add a card')}</span>
</button>
@@ -103,10 +96,6 @@ export default function CheckIn() {
<span className={'ci-dot' + (active >= cards.length ? ' on' : '')} />
</div>}
- {cards.length > 1 && <div className="muted small" style={{ textAlign: 'center', marginTop: 10 }}>
- {t('Long-press a card to reorder')}
- </div>}
-
{!cards.length && <div className="muted small" style={{ textAlign: 'center', marginTop: 18, lineHeight: 1.5 }}>
{t('Import a photo of your membership card or scan it with the camera. No extra app needed at the gym — just open this screen.')}
</div>}
@@ -115,8 +104,10 @@ export default function CheckIn() {
// One saved card: its label centered above the QR, and the raw value underneath (handy when a
// reader is fussy and a staff member types it in). The edit button opens the same sheet used to
-// add a card, pre-filled; the trash button removes it after a confirm.
-function CardFace({ card, dragging }) {
+// add a card, pre-filled; the trash button removes it after a confirm. With more than one card, a
+// row of ◀ ▶ buttons nudges this card one slot along the rail — a plain, reliable reorder that
+// doesn't fight the rail's horizontal scroll the way a drag gesture did.
+function CardFace({ card, index, count }) {
const update = useStore(s => s.update)
const remove = () => confirmSheet({
title: t('Remove this card?'),
@@ -128,111 +119,23 @@ function CardFace({ card, dragging }) {
if (s.lastGymCardId === card.id) s.lastGymCardId = (s.gymCards[0]?.id) || null
}),
})
- return <div className={'ci-card' + (dragging ? ' is-dragging' : '')} data-ci-card data-ci-id={card.id}>
+ const move = to => update(s => { s.gymCards = moveGymCard(s.gymCards, index, to) })
+ return <div className="ci-card">
<div className="ci-card-hd">
- <button className="iconbtn ci-card-btn" onClick={() => openEditCard(card)} aria-label={t('Edit')} data-nodrag><Icon name="pencil" /></button>
+ <button className="iconbtn ci-card-btn" onClick={() => openEditCard(card)} aria-label={t('Edit')}><Icon name="pencil" /></button>
<div className="ci-label">{card.label}</div>
- <button className="iconbtn ci-card-btn" style={{ color: 'var(--red)' }} onClick={remove} aria-label={t('Remove')} data-nodrag><Icon name="trash" /></button>
+ <button className="iconbtn ci-card-btn" style={{ color: 'var(--red)' }} onClick={remove} aria-label={t('Remove')}><Icon name="trash" /></button>
</div>
<div className="ci-qr-plate"><QrCanvas value={card.value} size={230} /></div>
<div className="ci-value">{card.value}</div>
+ {count > 1 && <div className="ci-reorder">
+ <button className="iconbtn ci-card-btn" onClick={() => move(index - 1)} disabled={index === 0} aria-label={t('Move left')}><Icon name="chevronLeft" /></button>
+ <span className="ci-pos">{index + 1} / {count}</span>
+ <button className="iconbtn ci-card-btn" onClick={() => move(index + 1)} disabled={index === count - 1} aria-label={t('Move right')}><Icon name="chevronRight" /></button>
+ </div>}
</div>
}
-/* ------------------------------------------------------- long-press reorder -- */
-
-// Horizontal drag-to-reorder for the rail. A long-press lifts the card under the finger; moving
-// then drops it before whichever card its centre passes. Kept self-contained (not the routine
-// editor's vertical hook) because the rail is a scroll-snap track, not a stacked list — the
-// gesture maths is horizontal and the scroll container is the element itself.
-//
-// Returns { dragging, dragId } for styling; the reorder itself is committed to the store on drop.
-function useRailReorder(railRef, cards) {
- const [state, setState] = useState({ dragging: false, dragId: null })
- const cardsRef = useRef(cards)
- cardsRef.current = cards
-
- useEffect(() => {
- const rail = railRef.current
- if (!rail) return undefined
- let gesture = null
-
- const clearTimer = () => { if (gesture?.timer) { clearTimeout(gesture.timer); gesture.timer = null } }
-
- const lift = g => {
- g.active = true
- setState({ dragging: true, dragId: g.id })
- }
-
- // Drop before the card whose horizontal centre the pointer has passed, then persist the new
- // order. A no-op move (dropped in place) still clears state but writes nothing.
- const drop = g => {
- const list = cardsRef.current
- const from = list.findIndex(c => c.id === g.id)
- if (from >= 0) {
- const cardEls = [...rail.querySelectorAll('[data-ci-card]')]
- const centres = cardEls.map(el => { const r = el.getBoundingClientRect(); return r.left + r.width / 2 })
- const to = centres.reduce((n, cx, i) => n + (i !== from && g.lastX > cx ? 1 : 0), 0)
- if (to !== from) useStore.getState().update(s => { s.gymCards = moveGymCard(s.gymCards, from, to) })
- }
- setState({ dragging: false, dragId: null })
- }
-
- const onPointerDown = event => {
- if (event.isPrimary === false || (event.pointerType === 'mouse' && event.button !== 0)) return
- const target = event.target
- if (!target?.closest || target.closest('button,a,input,textarea,select,[data-nodrag]')) return
- const cardEl = target.closest('[data-ci-card]')
- if (!cardEl || !rail.contains(cardEl)) return
- gesture = { id: cardEl.dataset.ciId, pointerId: event.pointerId, startX: event.clientX, lastX: event.clientX, active: false, timer: null }
- gesture.timer = window.setTimeout(() => lift(gesture), CI_LONG_PRESS_MS)
- }
-
- const onPointerMove = event => {
- if (!gesture || event.pointerId !== gesture.pointerId) return
- gesture.lastX = event.clientX
- if (!gesture.active) {
- // Moved before the long-press fired — it's a swipe of the rail, not a reorder. Bail so the
- // native scroll-snap takes over.
- if (Math.abs(event.clientX - gesture.startX) > CI_DRAG_SLOP) { clearTimer(); gesture = null }
- return
- }
- event.preventDefault()
- }
-
- const onPointerUp = event => {
- if (!gesture || event.pointerId !== gesture.pointerId) return
- clearTimer()
- if (gesture.active) drop(gesture)
- gesture = null
- }
-
- const cancel = () => { if (gesture) { clearTimer(); if (gesture.active) setState({ dragging: false, dragId: null }); gesture = null } }
-
- // Once a drag is active the rail must not also pan-scroll; a non-passive touchmove is the only
- // thing that can stop the browser claiming the gesture as a horizontal pan.
- const onTouchMove = event => { if (gesture?.active) event.preventDefault() }
-
- document.addEventListener('pointerdown', onPointerDown)
- document.addEventListener('pointermove', onPointerMove, { passive: false })
- document.addEventListener('pointerup', onPointerUp)
- document.addEventListener('pointercancel', cancel)
- rail.addEventListener('touchmove', onTouchMove, { passive: false })
- window.addEventListener('blur', cancel)
- return () => {
- cancel()
- document.removeEventListener('pointerdown', onPointerDown)
- document.removeEventListener('pointermove', onPointerMove)
- document.removeEventListener('pointerup', onPointerUp)
- document.removeEventListener('pointercancel', cancel)
- rail.removeEventListener('touchmove', onTouchMove)
- window.removeEventListener('blur', cancel)
- }
- }, [railRef])
-
- return state
-}
-
/* ------------------------------------------------------------- add/edit sheet -- */
// Opens the add-card sheet. Co-located with the view (not sheets.jsx) because it pulls in the
diff --git a/frontend/src/views/CheckIn.reorder.test.jsx b/frontend/src/views/CheckIn.reorder.test.jsx
index 6e3d97da8..9ce35aa96 100644
--- a/frontend/src/views/CheckIn.reorder.test.jsx
+++ b/frontend/src/views/CheckIn.reorder.test.jsx
@@ -1,10 +1,10 @@
// @vitest-environment happy-dom
// @vitest-environment happy-dom
-// The rail's reorder maths. The drop handler in CheckIn.jsx turns a pointer position into a target
-// index; moveGymCard is the pure part that then rearranges the array. These tests cover that
-// contract — a move is a splice, the input is never mutated, and degenerate moves (in place, out of
-// range) are safe no-ops — the same shape reorderRoutineUnit is tested to.
+// moveGymCard backs the on-card ◀ ▶ reorder buttons: it moves the card at `from` to index `to`,
+// returning a new array. These tests cover that contract — a move is a splice, the input is never
+// mutated, and degenerate moves (in place, out of range, past the ends) are safe no-ops, so a
+// button at either end of the rail is simply inert.
//
// moveGymCard itself is pure, but importing CheckIn.jsx loads the store (which registers a
// visibilitychange listener at module load) and the scanner/sheet modules, so the file runs under