mirror of
https://github.com/zotero/zotero.git
synced 2026-09-11 22:51:15 +00:00
Serialize lookup requests
These were switched to parallel in86b77cc45, resulting in blocks: https://forums.zotero.org/discussion/106658/limited-amount-of-articles-that-can-be-added-through-pmid (cherry picked from commitfcc68d6d80)
This commit is contained in:
parent
fb148497ba
commit
4db311eb46
2 changed files with 10 additions and 10 deletions
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<boolean>}
|
||||
* @returns {Promise<Zotero.Item[]>}
|
||||
*/
|
||||
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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue