Signed in, the server's profile is the truth: sign-in and pairing adopt it and ask once about workouts logged while signed out (Add them / Keep profile as is); the app polls the revision every 30 s and on every resume (GET /api/data/rev) and fetches only what moved; offline and unsynced states show a banner, retry on reconnect and confirm with a toast; pagehide flushes a pending change
This commit is contained in:
1 parent
28a068b8f0
commit
826432a3a2
30 files changed
+541
-37
No files matched your search
+14
-3
@@ -45,15 +45,26 @@ const toast = m => ui().toast(m)
|
||||
const snd = () => S().sound
|
||||
|
||||
/* ============================ custom confirm dialog ============================ */
|
||||
function ConfirmDialog({ title, message, confirmText, cancelText, danger, onConfirm, close }) {
|
||||
function ConfirmDialog({ title, message, confirmText, cancelText, danger, onConfirm, onCancel, close }) {
|
||||
return <div style={{ textAlign: 'center', padding: '4px 0' }}>
|
||||
{title && <h3 style={{ marginBottom: 8 }}>{title}</h3>}
|
||||
<div className="muted" style={{ marginBottom: 18, lineHeight: 1.5 }}>{message}</div>
|
||||
<button className={'btn ' + (danger ? 'danger' : 'primary')} onClick={() => { close(); onConfirm && onConfirm() }}>{confirmText || t('Confirm')}</button>
|
||||
<div style={{ height: 8 }} />
|
||||
<Button variant="ghost" className="dim" onClick={close}>{cancelText || t('Cancel')}</Button>
|
||||
<Button variant="ghost" className="dim" onClick={() => { close(); onCancel && onCancel() }}>{cancelText || t('Cancel')}</Button>
|
||||
</div>
|
||||
}
|
||||
// Sign-in found workouts on this device that the profile does not have (logged while signed
|
||||
// out). The profile is the truth — settings and plan come from the server either way — the
|
||||
// question is only whether these entries are added to it or dropped. Resolves true to add.
|
||||
export function askAddDeviceData(extras) {
|
||||
return new Promise(resolve => confirmSheet({
|
||||
title: t('Add this device\'s workouts to your profile?'),
|
||||
message: t('{0} workouts and {1} weigh-ins were logged on this device while signed out. Add them to your profile, or keep the profile exactly as it is on the server.', extras.workouts, extras.bodyweight),
|
||||
confirmText: t('Add them'), cancelText: t('Keep profile as is'),
|
||||
onConfirm: () => resolve(true), onCancel: () => resolve(false), locked: true
|
||||
}))
|
||||
}
|
||||
/* ============================ menu sheet ============================ */
|
||||
// A list of actions, one per row, closing on tap. This is where the workout screen parks
|
||||
// everything that is not a set you are about to log: the point of a single "more" button is
|
||||
@@ -81,7 +92,7 @@ export function menuSheet(opts) {
|
||||
|
||||
// Themed replacement for window.confirm — callback-based (no blocking).
|
||||
export function confirmSheet(opts) {
|
||||
ui().openSheet(close => <ConfirmDialog {...opts} close={close} />, { kind: 'center' })
|
||||
ui().openSheet(close => <ConfirmDialog {...opts} close={close} />, { kind: 'center', ...(opts.locked ? { locked: true } : {}) })
|
||||
}
|
||||
|
||||
/* ============================ starter plan ============================ */
|
||||
|
||||
Reference in new issue
Block a user