fix: snapshot pre-update state to enable 3-way merge on concurrent PATCH

Co-authored-by: fredicious <1580688+fredicious@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-03-12 20:19:10 +01:00
committed by Fred Cabassut
co-authored by fredicious
parent 9ed5c52fb6
commit ff3570f5ad
+7 -10
View File
@@ -330,16 +330,13 @@ export function updateNote(db: Db, userId: number, id: string, input: UpdateNote
(input.checklistMode !== undefined && input.checklistMode !== existing.checklistMode);
if (hasActualContentChange) {
const saved = db.select().from(notes).where(eq(notes.id, id)).get();
if (saved) {
createSnapshot(db, id, {
version: saved.version,
title: saved.title,
content: saved.content,
checklistMode: saved.checklistMode,
color: saved.color
});
}
createSnapshot(db, id, {
version: existing.version,
title: existing.title,
content: existing.content,
checklistMode: existing.checklistMode,
color: existing.color
});
}
return getNote(db, userId, id);