Add items from RecognizePDF in a DB transaction
This commit is contained in:
parent
d7e38d960e
commit
5c9fce9a9d
1 changed files with 10 additions and 8 deletions
|
@ -396,14 +396,16 @@ var Zotero_RecognizePDF = new function() {
|
||||||
|
|
||||||
// put new item in same collections as the old one
|
// put new item in same collections as the old one
|
||||||
let itemCollections = item.getCollections();
|
let itemCollections = item.getCollections();
|
||||||
for (let i = 0; i < itemCollections.length; i++) {
|
yield Zotero.DB.executeTransaction(function* () {
|
||||||
let collection = yield Zotero.Collections.getAsync(itemCollections[i]);
|
for (let i = 0; i < itemCollections.length; i++) {
|
||||||
yield collection.addItem(newItem.id);
|
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;
|
// put old item as a child of the new item
|
||||||
yield item.saveTx();
|
item.parentID = newItem.id;
|
||||||
|
yield item.save();
|
||||||
|
});
|
||||||
|
|
||||||
itemTitle.setAttribute("label", newItem.getField("title"));
|
itemTitle.setAttribute("label", newItem.getField("title"));
|
||||||
itemIcon.setAttribute("src", SUCCESS_IMAGE);
|
itemIcon.setAttribute("src", SUCCESS_IMAGE);
|
||||||
|
|
Loading…
Add table
Reference in a new issue