Skip to content

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

web: refresh app on sync merge conflict

Abdullah Atta961b953f5acc
diff --git a/apps/web/src/stores/app-store.js b/apps/web/src/stores/app-store.js
index 6edfca85d..c1c7176ee 100644
--- a/apps/web/src/stores/app-store.js
+++ b/apps/web/src/stores/app-store.js
@@ -274,7 +274,7 @@ class AppStore extends BaseStore {
await this.updateLastSynced();
} catch (err) {
logger.error(err);
- if (err.code === "MERGE_CONFLICT") {
+ if (err.cause === "MERGE_CONFLICT") {
if (editorstore.get().session.id)
editorstore.openSession(editorstore.get().session.id, true);
await this.refresh();
diff --git a/packages/core/api/sync/conflicts.js b/packages/core/api/sync/conflicts.js
index e8b23b0f8..65ba10fca 100644
--- a/packages/core/api/sync/conflicts.js
+++ b/packages/core/api/sync/conflicts.js
@@ -35,5 +35,12 @@ class Conflicts {
check() {
return this._db.storage.read("hasConflicts");
}
+
+ throw() {
+ throw new Error(
+ "Merge conflicts detected. Please resolve all conflicts to continue syncing.",
+ { cause: "MERGE_CONFLICT" }
+ );
+ }
}
export default Conflicts;
diff --git a/packages/core/api/sync/index.js b/packages/core/api/sync/index.js
index 99cfe47ec..c059b6bc5 100644
--- a/packages/core/api/sync/index.js
+++ b/packages/core/api/sync/index.js
@@ -217,9 +217,7 @@ class Sync {
await this.conflicts.recalculate();
if (await this.conflicts.check()) {
- throw new Error(
- "Merge conflicts detected. Please resolve all conflicts to continue syncing."
- );
+ this.conflicts.throw();
}
let lastSynced = await this.db.lastSynced();
@@ -264,9 +262,7 @@ class Sync {
});
if (await this.conflicts.check()) {
- throw new Error(
- "Merge conflicts detected. Please resolve all conflicts to continue syncing."
- );
+ this.conflicts.throw();
}
return serverResponse;