Migrate Zotero.Promise.map() in syncFullTextEngine.js

Fixes syncing, I think.
This commit is contained in:
Abe Jellinek 2025-07-02 10:39:28 -04:00 • committed by Dan Stillman
parent 14afba4b62
commit da6efecaef

View file

@ -96,23 +96,20 @@ Zotero.Sync.Data.FullTextEngine.prototype._download = async function (libraryVer
keys.push(key);
}
this.requestPromises = [];
await // FIXME: fx140: replace call to Zotero.Promise.map()
Zotero.Promise.map(keys, (key) => {
this._stopCheck();
return this.apiClient.getFullTextForItem(
this.library.libraryType, this.library.libraryTypeID, key
)
.then((results) => {
// Process batches of 8 keys concurrently
await Zotero.Utilities.Internal.forEachChunkAsync(keys, 8, async (keys) => {
await Promise.all(keys.map(async (key) => {
this._stopCheck();
let results = await this.apiClient.getFullTextForItem(
this.library.libraryType, this.library.libraryTypeID, key
);
this._stopCheck();
if (!results) return;
return Zotero.Fulltext.setItemContent(
await Zotero.Fulltext.setItemContent(
this.libraryID, key, results.data, results.version
)
})
}, // Prepare twice the number of concurrent requests
{ concurrency: 8 });
);
}));
});
await Zotero.FullText.setLibraryVersion(this.libraryID, results.libraryVersion);
};