mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 23:19:40 +01:00
core: filter out conflicted notes & content during sync
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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)])
|
||||
|
||||
Reference in New Issue
Block a user