Skip to content

Commit 11075bb

Browse files
author
djinni-hppro
committed
...
1 parent fbbd8a7 commit 11075bb

1 file changed

Lines changed: 19 additions & 5 deletions

File tree

src/helpers.js

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -405,13 +405,27 @@ async function syncDeletedNoteIds({deletedNoteIds, credentials, gitCredentials,
405405
});
406406

407407
// --- Upload Phase ---
408-
// 3. Only upload if the merged list differs from what we had before
409-
// (compare against the most recent remote OR local if no remotes)
410-
const referenceIds = remoteLists.length > 0 ? initialMasterIds : new Set(deletedNoteIds);
411-
const hasChanged = finalIds.size !== referenceIds.size || ![...finalIds].every(id => referenceIds.has(id));
412-
413408
const finalIdArray = Array.from(finalIds).slice(-100);
414409

410+
// Check if the merged result differs from all remotes
411+
// Only upload if at least one remote doesn't have the merged list
412+
let hasChanged = false;
413+
414+
if (remoteLists.length === 0) {
415+
// No remotes: only upload if we have local deletions to persist
416+
hasChanged = deletedNoteIds.length > 0;
417+
} else {
418+
// Check if all remotes already have the merged list
419+
for (const remote of remoteLists) {
420+
const remoteSet = new Set(remote.ids);
421+
const remoteMatches = remoteSet.size === finalIds.size && [...finalIds].every(id => remoteSet.has(id));
422+
if (!remoteMatches) {
423+
hasChanged = true;
424+
break;
425+
}
426+
}
427+
}
428+
415429
if (hasChanged) {
416430
console.log('Deleted notes list has changed, uploading to all providers.');
417431
const uploadPromises = [];

0 commit comments

Comments
 (0)