Add items from RecognizePDF in a DB transaction

This commit is contained in:
LinuxMercedes 2016-05-26 14:35:41 -05:00
parent d7e38d960e
commit 5c9fce9a9d

View file

@ -396,14 +396,16 @@ var Zotero_RecognizePDF = new function() {
// put new item in same collections as the old one
let itemCollections = item.getCollections();
for (let i = 0; i < itemCollections.length; i++) {
let collection = yield Zotero.Collections.getAsync(itemCollections[i]);
yield collection.addItem(newItem.id);
}
// put old item as a child of the new item
item.parentID = newItem.id;
yield item.saveTx();
yield Zotero.DB.executeTransaction(function* () {
for (let i = 0; i < itemCollections.length; i++) {
let collection = Zotero.Collections.get(itemCollections[i]);
yield collection.addItem(newItem.id);
}
// put old item as a child of the new item
item.parentID = newItem.id;
yield item.save();
});
itemTitle.setAttribute("label", newItem.getField("title"));
itemIcon.setAttribute("src", SUCCESS_IMAGE);