mobile: opcion de auto-backup local al terminar entreno o editar rutina
En el build movil (Capacitor) los datos solo viven en el dispositivo, sin backend. Ademas del export/import manual ya existente, se agrega un toggle en Settings que escribe una copia fechada en la carpeta Documents (visible en Files/gestor de archivos) tras terminar un entrenamiento o salir del editor de rutinas, para que una app de sincronizacion externa (o una copia manual) siempre tenga algo reciente que llevarse.
This commit is contained in:
1 parent
02ea938b2c
commit
50194442b6
6 files changed
+39
-2
No files matched your search
@@ -21,6 +21,10 @@ export default function RoutineEdit() {
|
||||
const update = useStore(s => s.update)
|
||||
const r = S.routines.find(x => x.id === id)
|
||||
useEffect(() => { if (!r) nav('/plan') }, [!!r])
|
||||
// Editing here has no explicit "save" — every field change persists immediately. A single
|
||||
// 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) })
|
||||
|
||||
@@ -186,6 +186,10 @@ export default function Settings() {
|
||||
accessory="chevron" onClick={() => importRef.current.click()} />
|
||||
<Row icon="upload" iconTint="var(--blue)" title={t('Import backup')} accessory="chevron" onClick={() => fileRef.current.click()} />
|
||||
<Row icon="download" iconTint="var(--blue)" title={t('Export backup (JSON)')} accessory="chevron" onClick={doExport} />
|
||||
{MOBILE && <Row icon="history" iconTint="var(--blue)" title={t('Auto-backup on changes')}
|
||||
subtitle={t('Saves a dated copy to the Documents folder after finishing a workout or editing a routine — point a sync app at it, or copy it out by hand.')}>
|
||||
<Switch checked={!!S.autoBackup} onChange={v => update(s => { s.autoBackup = v })} />
|
||||
</Row>}
|
||||
<Row icon="trash" iconTint="var(--red)" title={t('Reset everything')} danger onClick={() => confirmSheet({ title: t('Reset everything?'), message: t('Deletes your plan, workouts and body weight on this device. This cannot be undone.'), confirmText: t('Delete everything'), danger: true, onConfirm: () => { replaceState(JSON.parse(JSON.stringify(DEF)), true); nav('/home'); toast(t('All data reset')) } })} />
|
||||
</Section>
|
||||
<input ref={fileRef} type="file" accept=".json,application/json" style={{ display: 'none' }} onChange={doImport} />
|
||||
|
||||
Reference in new issue
Block a user