feat(settings): a switch to skip the weigh-in when a workout starts (#137)
Settings → During a workout → "Weigh in before workouts", on by default. Off, tapping Start begins the session straight away with no body weight on it — what "Start without weighing in" did, without the sheet. Home and Stats still log weight by hand, and the Home body-weight footer stops promising "it's also asked before every workout" while it is off. S.weighIn (DEF true, read as `!== false` so older profiles keep asking, same as checkIn). startFlow is the single entry point for every Start button, so the check lives there; "log a past workout" never asked and is unchanged. Three new strings in all 14 locales, pt-BR as explicit overrides (inherited set and fingerprint unchanged). Test: sheets.weighin.test.jsx — on / legacy profile / off, through the real store and sheet stack. Closes #137.
This commit is contained in:
1 parent
35c810a663
commit
ebe00a1122
20 files changed
+101
-2
No files matched your search
@@ -27,7 +27,7 @@ describe('Brazilian Portuguese locale', () => {
|
||||
.sort(byCodeUnit)
|
||||
const fingerprint = createHash('sha256').update(JSON.stringify(inherited)).digest('hex')
|
||||
|
||||
expect(Object.keys(PT_BR_OVERRIDES)).toHaveLength(635)
|
||||
expect(Object.keys(PT_BR_OVERRIDES)).toHaveLength(638)
|
||||
expect(inherited).toHaveLength(639)
|
||||
// If this fails, review the changed keys and wording before accepting a new hash. From
|
||||
// frontend/: node scripts/pt-br-inheritance-fingerprint.mjs --list
|
||||
|
||||
@@ -336,6 +336,9 @@ export default {
|
||||
'Rest timer': 'Pausen-Timer',
|
||||
'Sounds': 'Töne',
|
||||
'Flash screen when timer ends': 'Bildschirm bei Timer-Ende blinken lassen',
|
||||
'Weigh in before workouts': 'Vor dem Training wiegen',
|
||||
'Asks for your body weight when a workout starts. Off starts the session straight away.': 'Fragt beim Start eines Trainings nach deinem Körpergewicht. Aus startet die Einheit direkt.',
|
||||
'No entries yet — log your weight to start the curve.': 'Noch keine Einträge — trag dein Gewicht ein, um die Kurve zu starten.',
|
||||
'Data': 'Daten',
|
||||
'Export backup (JSON)': 'Backup exportieren (JSON)',
|
||||
'Import backup': 'Backup importieren',
|
||||
|
||||
@@ -321,6 +321,9 @@ export default {
|
||||
'Rest timer': 'Temporizador de descanso',
|
||||
'Sounds': 'Sonidos',
|
||||
'Flash screen when timer ends': 'Hacer parpadear la pantalla al finalizar el temporizador',
|
||||
'Weigh in before workouts': 'Pesarse antes de entrenar',
|
||||
'Asks for your body weight when a workout starts. Off starts the session straight away.': 'Pide tu peso corporal al empezar un entrenamiento. Desactivado, la sesión empieza directamente.',
|
||||
'No entries yet — log your weight to start the curve.': 'Sin registros aún — apunta tu peso para empezar la curva.',
|
||||
'Data': 'Datos',
|
||||
'Export backup (JSON)': 'Exportar copia (JSON)',
|
||||
'Import backup': 'Importar copia',
|
||||
|
||||
@@ -321,6 +321,9 @@ export default {
|
||||
'Rest timer': 'Minuteur de repos',
|
||||
'Sounds': 'Sons',
|
||||
'Flash screen when timer ends': 'Faire clignoter l’écran à la fin du minuteur',
|
||||
'Weigh in before workouts': 'Se peser avant la séance',
|
||||
'Asks for your body weight when a workout starts. Off starts the session straight away.': 'Demande ton poids au début d’une séance. Désactivé, la séance démarre directement.',
|
||||
'No entries yet — log your weight to start the curve.': 'Aucune entrée — note ton poids pour démarrer la courbe.',
|
||||
'Data': 'Données',
|
||||
'Export backup (JSON)': 'Exporter une sauvegarde (JSON)',
|
||||
'Import backup': 'Importer une sauvegarde',
|
||||
|
||||
@@ -321,6 +321,9 @@ export default {
|
||||
'Rest timer': 'आराम टाइमर',
|
||||
'Sounds': 'ध्वनियाँ',
|
||||
'Flash screen when timer ends': 'टाइमर खत्म होने पर स्क्रीन फ्लैश करें',
|
||||
'Weigh in before workouts': 'वर्कआउट से पहले वज़न दर्ज करना',
|
||||
'Asks for your body weight when a workout starts. Off starts the session straight away.': 'वर्कआउट शुरू होते समय आपका वज़न पूछता है। बंद होने पर सेशन सीधे शुरू होता है।',
|
||||
'No entries yet — log your weight to start the curve.': 'अभी कोई एंट्री नहीं — ग्राफ़ शुरू करने के लिए वज़न दर्ज करें।',
|
||||
'Data': 'डेटा',
|
||||
'Export backup (JSON)': 'बैकअप निर्यात करें (JSON)',
|
||||
'Import backup': 'बैकअप आयात करें',
|
||||
|
||||
@@ -745,6 +745,9 @@ export default {
|
||||
'Logged sets stay with the original exercise. The replacement will be inserted afterward.': 'A naplózott sorozatok az eredeti gyakorlatnál maradnak. A csere utána kerül beszúrásra.',
|
||||
'Rest after each set of this exercise. Leave at 0 to use your default rest timer.': 'Pihenő a gyakorlat minden sorozata után. Hagyd 0-n az alapértelmezett pihenőidőzítőhöz.',
|
||||
'Flash screen when timer ends': 'Képernyő villogása, ha lejár az időzítő',
|
||||
'Weigh in before workouts': 'Súlymérés edzés előtt',
|
||||
'Asks for your body weight when a workout starts. Off starts the session straight away.': 'Edzés indításakor rákérdez a testsúlyodra. Kikapcsolva az edzés azonnal indul.',
|
||||
'No entries yet — log your weight to start the curve.': 'Még nincs bejegyzés — rögzítsd a súlyodat a görbe elindításához.',
|
||||
'Import from Hevy': 'Importálás a Hevyből',
|
||||
'Pull your history with a Hevy Pro API key': 'Előzmények letöltése Hevy Pro API-kulccsal',
|
||||
'Pull your history with a Hevy Pro API key. The key is only used for this import and is not saved.': 'Előzmények letöltése Hevy Pro API-kulccsal. A kulcs csak ehhez az importhoz kell, nem mentjük el.',
|
||||
|
||||
@@ -321,6 +321,9 @@ export default {
|
||||
'Rest timer': 'Timer di riposo',
|
||||
'Sounds': 'Suoni',
|
||||
'Flash screen when timer ends': 'Fai lampeggiare lo schermo alla fine del timer',
|
||||
'Weigh in before workouts': 'Pesarsi prima dell’allenamento',
|
||||
'Asks for your body weight when a workout starts. Off starts the session straight away.': 'Chiede il tuo peso all’avvio di un allenamento. Disattivato, la sessione parte subito.',
|
||||
'No entries yet — log your weight to start the curve.': 'Nessun dato — registra il tuo peso per iniziare la curva.',
|
||||
'Data': 'Dati',
|
||||
'Export backup (JSON)': 'Esporta backup (JSON)',
|
||||
'Import backup': 'Importa backup',
|
||||
|
||||
@@ -321,6 +321,9 @@ export default {
|
||||
'Rest timer': '휴식 타이머',
|
||||
'Sounds': '소리',
|
||||
'Flash screen when timer ends': '타이머 종료 시 화면 깜박임',
|
||||
'Weigh in before workouts': '운동 전 체중 기록',
|
||||
'Asks for your body weight when a workout starts. Off starts the session straight away.': '운동을 시작할 때 체중을 물어봅니다. 끄면 세션이 바로 시작됩니다.',
|
||||
'No entries yet — log your weight to start the curve.': '아직 기록이 없어요 — 체중을 기록해 그래프를 시작하세요.',
|
||||
'Data': '데이터',
|
||||
'Export backup (JSON)': '백업 내보내기 (JSON)',
|
||||
'Import backup': '백업 가져오기',
|
||||
|
||||
@@ -321,6 +321,9 @@ export default {
|
||||
'Rest timer': 'Minutnik przerwy',
|
||||
'Sounds': 'Dźwięki',
|
||||
'Flash screen when timer ends': 'Migaj ekranem po zakończeniu minutnika',
|
||||
'Weigh in before workouts': 'Ważenie przed treningiem',
|
||||
'Asks for your body weight when a workout starts. Off starts the session straight away.': 'Pyta o Twoją masę ciała przy rozpoczęciu treningu. Wyłączone — sesja zaczyna się od razu.',
|
||||
'No entries yet — log your weight to start the curve.': 'Brak wpisów — zapisz wagę, aby zacząć krzywą.',
|
||||
'Data': 'Dane',
|
||||
'Export backup (JSON)': 'Eksportuj kopię (JSON)',
|
||||
'Import backup': 'Importuj kopię',
|
||||
|
||||
@@ -111,6 +111,9 @@ export const PT_BR_OVERRIDES = {
|
||||
'synced with your profile': 'sincronizado com seu perfil',
|
||||
'The screen stays on while a workout is running, so you don’t have to unlock your phone between sets.': 'A tela permanece ligada durante o treino, para você não precisar desbloquear o celular entre as séries.',
|
||||
'Flash screen when timer ends': 'Piscar a tela quando o temporizador terminar',
|
||||
'Weigh in before workouts': 'Pesar antes do treino',
|
||||
'Asks for your body weight when a workout starts. Off starts the session straight away.': 'Pede seu peso ao iniciar um treino. Desligado, a sessão começa na hora.',
|
||||
'No entries yet — log your weight to start the curve.': 'Ainda não há registros — informe seu peso para começar a curva.',
|
||||
'Export backup (JSON)': 'Exportar backup (JSON)',
|
||||
'Import backup': 'Importar backup',
|
||||
'Reset everything?': 'Redefinir tudo?',
|
||||
|
||||
@@ -321,6 +321,9 @@ export default {
|
||||
'Rest timer': 'Temporizador de descanso',
|
||||
'Sounds': 'Sons',
|
||||
'Flash screen when timer ends': 'Piscar o ecrã quando o temporizador terminar',
|
||||
'Weigh in before workouts': 'Pesar antes do treino',
|
||||
'Asks for your body weight when a workout starts. Off starts the session straight away.': 'Pede o teu peso ao iniciar um treino. Desligado, a sessão começa de imediato.',
|
||||
'No entries yet — log your weight to start the curve.': 'Ainda sem registos — regista o teu peso para começar a curva.',
|
||||
'Data': 'Dados',
|
||||
'Export backup (JSON)': 'Exportar cópia (JSON)',
|
||||
'Import backup': 'Importar cópia',
|
||||
|
||||
@@ -321,6 +321,9 @@ export default {
|
||||
'Rest timer': 'Таймер отдыха',
|
||||
'Sounds': 'Звуки',
|
||||
'Flash screen when timer ends': 'Мигать экраном по окончании таймера',
|
||||
'Weigh in before workouts': 'Взвешивание перед тренировкой',
|
||||
'Asks for your body weight when a workout starts. Off starts the session straight away.': 'Спрашивает ваш вес при начале тренировки. Выключено — сессия начинается сразу.',
|
||||
'No entries yet — log your weight to start the curve.': 'Записей пока нет — внеси вес, чтобы начать кривую.',
|
||||
'Data': 'Данные',
|
||||
'Export backup (JSON)': 'Экспорт резервной копии (JSON)',
|
||||
'Import backup': 'Импорт резервной копии',
|
||||
|
||||
@@ -753,6 +753,9 @@ export default {
|
||||
'Logged sets stay with the original exercise. The replacement will be inserted afterward.': 'เซ็ตที่บันทึกแล้วจะอยู่กับท่าเดิม ท่าใหม่จะถูกแทรกไว้ถัดไป',
|
||||
'Rest after each set of this exercise. Leave at 0 to use your default rest timer.': 'พักหลังแต่ละเซ็ตของท่านี้ ปล่อยไว้ที่ 0 เพื่อใช้ตัวจับเวลาพักค่าเริ่มต้น',
|
||||
'Flash screen when timer ends': 'กะพริบหน้าจอเมื่อหมดเวลา',
|
||||
'Weigh in before workouts': 'ชั่งน้ำหนักก่อนออกกำลังกาย',
|
||||
'Asks for your body weight when a workout starts. Off starts the session straight away.': 'ถามน้ำหนักตัวเมื่อเริ่มออกกำลังกาย ถ้าปิด เซสชันจะเริ่มทันที',
|
||||
'No entries yet — log your weight to start the curve.': 'ยังไม่มีข้อมูล — บันทึกน้ำหนักเพื่อเริ่มกราฟ',
|
||||
'Import from Hevy': 'นำเข้าจาก Hevy',
|
||||
'Pull your history with a Hevy Pro API key': 'ดึงประวัติด้วยคีย์ API ของ Hevy Pro',
|
||||
'Pull your history with a Hevy Pro API key. The key is only used for this import and is not saved.': 'ดึงประวัติด้วยคีย์ API ของ Hevy Pro คีย์ใช้สำหรับการนำเข้าครั้งนี้เท่านั้นและจะไม่ถูกบันทึก',
|
||||
|
||||
@@ -321,6 +321,9 @@ export default {
|
||||
'Rest timer': 'Dinlenme sayacı',
|
||||
'Sounds': 'Sesler',
|
||||
'Flash screen when timer ends': 'Zamanlayıcı bitince ekranı yanıp söndür',
|
||||
'Weigh in before workouts': 'Antrenman öncesi tartılma',
|
||||
'Asks for your body weight when a workout starts. Off starts the session straight away.': 'Antrenman başlarken kilonu sorar. Kapalıyken seans hemen başlar.',
|
||||
'No entries yet — log your weight to start the curve.': 'Henüz kayıt yok — eğriyi başlatmak için kilonu gir.',
|
||||
'Data': 'Veriler',
|
||||
'Export backup (JSON)': 'Yedeği dışa aktar (JSON)',
|
||||
'Import backup': 'Yedeği içe aktar',
|
||||
|
||||
@@ -321,6 +321,9 @@ export default {
|
||||
'Rest timer': '休息计时',
|
||||
'Sounds': '声音',
|
||||
'Flash screen when timer ends': '计时结束时闪烁屏幕',
|
||||
'Weigh in before workouts': '训练前称重',
|
||||
'Asks for your body weight when a workout starts. Off starts the session straight away.': '开始训练时询问体重。关闭后直接进入训练。',
|
||||
'No entries yet — log your weight to start the curve.': '还没有记录——记录体重以开始曲线。',
|
||||
'Data': '数据',
|
||||
'Export backup (JSON)': '导出备份(JSON)',
|
||||
'Import backup': '导入备份',
|
||||
|
||||
@@ -1730,6 +1730,9 @@ export function WorkoutRow({ w, onClick }) {
|
||||
// `routineIds` accepts `string | string[] | null` — `[r.id]` for one routine,
|
||||
// `effectiveRoutineIds(...)` for today's planned session, `[]` / null for explicit freestyle.
|
||||
export function startFlow(routineIds) {
|
||||
// The weigh-in is a setting (Settings → During a workout, issue #137): off goes straight
|
||||
// into the session with no body weight on it, same as "Start without weighing in".
|
||||
if (S().weighIn === false) { beginWorkout(routineIds, null); return }
|
||||
bwSheet({ required: true, onDone: bw => beginWorkout(routineIds, bw) })
|
||||
}
|
||||
export function beginWorkout(routineIds, bw) {
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
// @vitest-environment happy-dom
|
||||
import { act } from 'react'
|
||||
import { beforeEach, describe, expect, it } from 'vitest'
|
||||
import { useStore } from './store/useStore.js'
|
||||
import { useUI } from './store/useUI.js'
|
||||
import { startFlow } from './sheets.jsx'
|
||||
|
||||
// Start opens the quick weigh-in unless Settings → During a workout → "Weigh in before
|
||||
// workouts" is off (issue #137) — then the session begins at once, with no body weight on it.
|
||||
|
||||
describe('the weigh-in before a workout is a setting', () => {
|
||||
beforeEach(() => {
|
||||
globalThis.IS_REACT_ACT_ENVIRONMENT = true
|
||||
useUI.setState({ sheets: [], toasts: [] })
|
||||
useStore.setState(s => ({ S: { ...s.S, active: null, routines: [], workouts: [], bodyweight: [], weighIn: true } }))
|
||||
})
|
||||
|
||||
it('on (the default): Start opens the weigh-in and the session waits for it', () => {
|
||||
act(() => startFlow([]))
|
||||
expect(useUI.getState().sheets).toHaveLength(1)
|
||||
expect(useUI.getState().sheets[0].locked).toBe(true) // the required weigh-in, not a plain sheet
|
||||
expect(useStore.getState().S.active).toBeNull()
|
||||
})
|
||||
|
||||
it('a profile written before the setting existed still asks', () => {
|
||||
useStore.setState(s => { const S = { ...s.S }; delete S.weighIn; return { S } })
|
||||
act(() => startFlow([]))
|
||||
expect(useUI.getState().sheets).toHaveLength(1)
|
||||
expect(useUI.getState().sheets[0].locked).toBe(true)
|
||||
expect(useStore.getState().S.active).toBeNull()
|
||||
})
|
||||
|
||||
it('off: Start begins the session at once, with no sheet and no body weight', () => {
|
||||
useStore.setState(s => ({ S: { ...s.S, weighIn: false } }))
|
||||
act(() => startFlow([]))
|
||||
expect(useUI.getState().sheets).toHaveLength(0)
|
||||
const { active } = useStore.getState().S
|
||||
expect(active).not.toBeNull()
|
||||
expect(active.bw).toBeNull()
|
||||
expect(active.routineIds).toEqual([])
|
||||
})
|
||||
})
|
||||
@@ -74,6 +74,10 @@ export const DEF = {
|
||||
// card and the /checkin route; the saved gymCards stay so turning it back on restores them.
|
||||
// Defaults on; an older profile without the key reads as on (`!== false`).
|
||||
checkIn: true,
|
||||
// Whether Start opens the quick weigh-in first (sheets.jsx startFlow, issue #137). Off starts
|
||||
// the session straight away; weight can still be logged from Home/Stats. Defaults on; an
|
||||
// older profile without the key reads as on (`!== false`).
|
||||
weighIn: true,
|
||||
}
|
||||
const clone = o => JSON.parse(JSON.stringify(o))
|
||||
|
||||
|
||||
@@ -155,7 +155,9 @@ export default function Home() {
|
||||
</div>
|
||||
)}
|
||||
<div className="chart" style={{ marginTop: 8 }}><LineChart points={bwPoints} h={130} unit={S.unit} goal={S.targetW} /></div>
|
||||
</> : <div className="muted small">{t("No entries yet — log your weight to start the curve. It's also asked before every workout.")}</div>}
|
||||
</> : <div className="muted small">{S.weighIn === false
|
||||
? t('No entries yet — log your weight to start the curve.')
|
||||
: t("No entries yet — log your weight to start the curve. It's also asked before every workout.")}</div>}
|
||||
</div>
|
||||
|
||||
<div className="card tappable" style={{ cursor: 'pointer' }} {...tappable(() => calendarSheet())}>
|
||||
|
||||
@@ -260,6 +260,12 @@ export default function Settings() {
|
||||
|
||||
{/* ---------- during a workout ---------- */}
|
||||
<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}>
|
||||
{/* The quick weigh-in that opens on Start (sheets.jsx startFlow, issue #137); off skips straight
|
||||
to the session. Home and Stats still log weight by hand. */}
|
||||
<Row icon="scale" iconTint="var(--green)" title={t('Weigh in before workouts')}
|
||||
subtitle={t('Asks for your body weight when a workout starts. Off starts the session straight away.')}>
|
||||
<Switch checked={S.weighIn !== false} onChange={v => update(s => { s.weighIn = v })} />
|
||||
</Row>
|
||||
{/* One exercise at a time (cards with Prev/Next), the whole session stacked as a
|
||||
scrollable list, or that list stripped to just names and set rows (compact).
|
||||
Legacy/unknown values read as cards. The running session can override this from
|
||||
|
||||
Reference in new issue
Block a user