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
@@ -855,6 +855,14 @@ const routes = {
|
||||
const state = readState(user.id);
|
||||
json(res, 200, { state, rev: state?._rev || 0 });
|
||||
},
|
||||
// Just the revision: the client asks this every half minute while it is open and on every
|
||||
// return to the foreground, and fetches the document only when the number moved — a signed-in
|
||||
// device is meant to show what the server has, and this is what keeps that cheap.
|
||||
'GET /api/data/rev': async (req, res) => {
|
||||
const user = readSession(req);
|
||||
if (!user) return json(res, 401, { error: 'not signed in' });
|
||||
json(res, 200, { rev: readState(user.id)?._rev || 0 });
|
||||
},
|
||||
|
||||
'PUT /api/data': async (req, res) => {
|
||||
const user = readSession(req);
|
||||
|
||||
Reference in new issue
Block a user