Skip to content

Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.

fix(sync): let the server stamp updated_at on note creates (#2065)

Chad Pihad0039ba06d8d
diff --git a/src/helpers/cloudSyncGuards.js b/src/helpers/cloudSyncGuards.js
index 497af2ef7..ecdb3d895 100644
--- a/src/helpers/cloudSyncGuards.js
+++ b/src/helpers/cloudSyncGuards.js
@@ -52,8 +52,14 @@ export function buildNoteUpdatePayload(note, cloudFolderId) {
// POST creates a new cloud identity and therefore has no prior server
// revision to compare. Forks from older databases can retain a stale base, so
// derive create payloads explicitly rather than forwarding base_updated_at.
+//
+// updated_at is dropped too so the server stamps the row itself. The local
+// value is the last edit, possibly hours old by the time the row uploads, and
+// the server stores it as-is — mobile's delta cursor (the newest updated_at
+// it has seen) would then skip the row forever. PATCHes are server-stamped.
export function buildNoteCreatePayload(note, cloudFolderId) {
const payload = buildNoteUpdatePayload(note, cloudFolderId);
delete payload.base_updated_at;
+ delete payload.updated_at;
return payload;
}
diff --git a/test/helpers/cloudSyncGuards.test.js b/test/helpers/cloudSyncGuards.test.js
index bce51e163..f0cd14ec7 100644
--- a/test/helpers/cloudSyncGuards.test.js
+++ b/test/helpers/cloudSyncGuards.test.js
@@ -138,3 +138,13 @@ test("note create payloads never send a stale optimistic-concurrency base", asyn
assert.equal(payload.content, localNote.content);
assert.equal(payload.folder_id, "cloud-folder-3");
});
+
+// A create carrying the local last-edit time lands behind mobile's delta
+// cursor when it uploads late (see buildNoteCreatePayload), so it must not.
+
+test("note create payloads let the server stamp updated_at", async () => {
+ const { buildNoteCreatePayload } = await load();
+ const payload = buildNoteCreatePayload(localNote, "cloud-folder-3");
+ assert.equal("updated_at" in payload, false);
+ assert.equal(payload.content, localNote.content);
+});