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
core: filter out conflicted notes & content during sync
Abdullah Attacf1b77425537
diff --git a/packages/core/src/api/sync/collector.ts b/packages/core/src/api/sync/collector.tsindex 396effbc4..e3d9289a5 100644--- a/packages/core/src/api/sync/collector.ts+++ b/packages/core/src/api/sync/collector.ts@@ -110,9 +110,6 @@ function filterSyncableItems(items: MaybeDeletedItem<Item>[]): {const ids = [];const syncableItems = [];for (const item of items) {- // do not sync conflicted note or content- if ("conflicted" in item && item.conflicted) continue;-delete item.synced;ids.push(item.id);diff --git a/packages/core/src/database/sql-collection.ts b/packages/core/src/database/sql-collection.tsindex f4d6f8c9e..d78e03892 100644--- a/packages/core/src/database/sql-collection.ts+++ b/packages/core/src/database/sql-collection.ts@@ -284,6 +284,12 @@ export class SQLCollection<.selectFrom<keyof DatabaseSchema>(this.type).select((a) => a.fn.count<number>("id").as("count")).where(isFalse("synced"))+ .$if(this.type === "content", (eb) =>+ eb.where("conflicted", "is", null)+ )+ .$if(this.type === "notes", (eb) =>+ eb.where("conflicted", "is not", true)+ ).$if(this.type === "attachments", (eb) =>eb.where((eb) =>eb.or([eb("dateUploaded", ">", 0), eb("deleted", "==", true)])@@ -304,6 +310,12 @@ export class SQLCollection<.selectAll().$if(lastRowId != null, (qb) => qb.where("id", ">", lastRowId!)).$if(!forceSync, (eb) => eb.where(isFalse("synced")))+ .$if(this.type === "content", (eb) =>+ eb.where("conflicted", "is", null)+ )+ .$if(this.type === "notes", (eb) =>+ eb.where("conflicted", "is not", true)+ ).$if(this.type === "attachments", (eb) =>eb.where((eb) =>eb.or([eb("dateUploaded", ">", 0), eb("deleted", "==", true)])