diff --git a/chrome/content/zotero/createParentDialog.js b/chrome/content/zotero/createParentDialog.js index 2253f7da05..47f6e47f93 100644 --- a/chrome/content/zotero/createParentDialog.js +++ b/chrome/content/zotero/createParentDialog.js @@ -68,7 +68,7 @@ async function doAccept() { ); // If we successfully created a parent, return it - if (newItems) { + if (newItems.length) { io.dataOut = { parent: newItems[0] }; window.close(); } diff --git a/chrome/content/zotero/lookup.js b/chrome/content/zotero/lookup.js index 60a563a1f1..02fb828935 100644 --- a/chrome/content/zotero/lookup.js +++ b/chrome/content/zotero/lookup.js @@ -40,7 +40,7 @@ var Zotero_Lookup = new function () { * @param textBox {HTMLElement} - Textbox containing identifiers * @param childItem {Zotero.Item|false} - Child item (optional) * @param toggleProgress {function} - Callback to toggle progress on/off - * @returns {Promise} + * @returns {Promise} */ this.addItemsFromIdentifier = async function (textBox, childItem, toggleProgress) { var identifiers = Zotero.Utilities.extractIdentifiers(textBox.value); @@ -79,11 +79,11 @@ var Zotero_Lookup = new function () { } } - let newItems = false; toggleProgress(true); - await Zotero.Promise.all(identifiers.map(async (identifier) => { - var translate = new Zotero.Translate.Search(); + let newItems = []; + for (let identifier of identifiers) { + let translate = new Zotero.Translate.Search(); translate.setIdentifier(identifier); // be lenient about translators @@ -91,20 +91,20 @@ var Zotero_Lookup = new function () { translate.setTranslator(translators); try { - newItems = await translate.translate({ + newItems.push(...await translate.translate({ libraryID, collections, saveAttachments: !childItem - }); + })); } // Continue with other ids on failure catch (e) { Zotero.logError(e); } - })); + } toggleProgress(false); - if (!newItems) { + if (!newItems.length) { Zotero.alert( window, Zotero.getString("lookup.failure.title"), @@ -126,7 +126,7 @@ var Zotero_Lookup = new function () { on => Zotero_Lookup.toggleProgress(on) ); - if (newItems) { + if (newItems.length) { document.getElementById("zotero-lookup-panel").hidePopup(); } return false;