A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
merger: keep most recent version if note is locked
thecodrr8546742124cb
diff --git a/packages/core/api/sync/merger.js b/packages/core/api/sync/merger.jsindex 4d83b351a..89fedf91b 100644--- a/packages/core/api/sync/merger.js+++ b/packages/core/api/sync/merger.js@@ -96,9 +96,20 @@ class Merger {(id) => this._db.delta.raw(id),(item) => this._db.delta.add(item),async (local, remote) => {- await this._db.delta.add({ ...local, conflicted: remote });- await this._db.notes.add({ id: local.noteId, conflicted: true });- await this._db.context.write("hasConflicts", true);+ // merge conflicts resolver+ const note = this._db.notes.note(local.noteId).data;++ if (note.locked) {+ // if note is locked we keep the most recent version.+ if (remote.dateEdited > local.dateEdited) {+ await this._db.delta.add({ id: local.id, ...remote });+ }+ } else {+ // otherwise we trigger the conflicts+ await this._db.delta.add({ ...local, conflicted: remote });+ await this._db.notes.add({ id: local.noteId, conflicted: true });+ await this._db.context.write("hasConflicts", true);+ }});