Fix descendant collections not skipping delete log

If a collection was deleted with `skipDeleteLog: true`, descendant
collections still ended up in the delete log, which could cause
constant "Reset Group and Sync" prompts.

https://forums.zotero.org/discussion/89485/warning-when-syncing-group-library
This commit is contained in:
Dan Stillman 2021-05-06 03:29:50 -04:00
parent 74b9604c7b
commit 6d5b00e94c
2 changed files with 20 additions and 0 deletions

View file

@ -607,6 +607,11 @@ Zotero.Collection.prototype._eraseData = Zotero.Promise.coroutine(function* (env
libraryID: c.libraryID,
key: c.key
};
// skipDeleteLog is normally added to notifierData in DataObject::_finalizeErase(),
// so we have to do it manually here
if (env.options && env.options.skipDeleteLog) {
env.notifierData[c.id].skipDeleteLog = true;
}
}
}
// Descendent items

View file

@ -61,6 +61,21 @@ describe("Zotero.Collection", function() {
yield collection.eraseTx({ deleteItems: true });
assert.lengthOf(item.getCollections(), 0);
});
it("should apply 'skipDeleteLog: true' to subcollections", async function () {
var collection1 = await createDataObject('collection');
var collection2 = await createDataObject('collection', { parentID: collection1.id });
var collection3 = await createDataObject('collection', { parentID: collection2.id });
await collection1.eraseTx({ skipDeleteLog: true });
var deleted = await Zotero.Sync.Data.Local.getDeleted('collection', collection1.libraryID);
// No collections should be in the delete log
assert.notInclude(deleted, collection1.key);
assert.notInclude(deleted, collection2.key);
assert.notInclude(deleted, collection3.key);
});
})
describe("#version", function () {