www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 5c9fce9a9dd39a0a801587274490ab364efe1406
parent d7e38d960e94c9ba24fe13269b3d43653df6e0cd
Author: LinuxMercedes <LinuxMercedes@gmail.com>
Date:   Thu, 26 May 2016 14:35:41 -0500

Add items from RecognizePDF in a DB transaction

Diffstat:
Mchrome/content/zotero/recognizePDF.js | 18++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/chrome/content/zotero/recognizePDF.js b/chrome/content/zotero/recognizePDF.js @@ -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);