Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

core: fix unintended merge conflicts

Abdullah Atta4ed378bc9c59
diff --git a/packages/core/api/sync/merger.js b/packages/core/api/sync/merger.js
index 1b978a8d2..484652d8a 100644
--- a/packages/core/api/sync/merger.js
+++ b/packages/core/api/sync/merger.js
@@ -177,7 +177,13 @@ class Merger {
return remoteItem;
} else {
const isResolved = localItem.dateResolved === remoteItem.dateModified;
- const isModified = localItem.dateModified > this._lastSynced;
+ const isModified =
+ // the local item is modified if it was changed/modified after the last sync
+ // i.e. it wasn't synced yet.
+ // However, in case a sync is interrupted the local item's date modified will
+ // be ahead of last sync. In that case, we also have to check if the synced flag
+ // is false (it is only false if a user makes edits on the local device).
+ localItem.dateModified > this._lastSynced && !localItem.synced;
if (isModified && !isResolved) {
// If time difference between local item's edits & remote item's edits
// is less than threshold, we shouldn't trigger a merge conflict; instead
@@ -200,7 +206,8 @@ class Merger {
isModified,
timeDiff,
remote: remoteItem.dateModified,
- local: localItem.dateModified
+ local: localItem.dateModified,
+ lastSynced: this._lastSynced
});
await markAsConflicted(localItem, remoteItem);