diff --git a/chrome/content/zotero/xpcom/data/dataObjects.js b/chrome/content/zotero/xpcom/data/dataObjects.js index 3907bedfe..38f3df535 100644 --- a/chrome/content/zotero/xpcom/data/dataObjects.js +++ b/chrome/content/zotero/xpcom/data/dataObjects.js @@ -460,7 +460,7 @@ Zotero.DataObjects.prototype.updateVersion = Zotero.Promise.method(function (ids return Zotero.Utilities.Internal.forEachChunkAsync( ids, Zotero.DB.MAX_BOUND_PARAMETERS, - function* (chunk) { + Zotero.Promise.coroutine(function* (chunk) { yield Zotero.DB.queryAsync(sql + chunk.map(() => '?').join(', ') + ')', chunk); // Update the internal 'version' property of any loaded objects for (let i = 0; i < chunk.length; i++) { @@ -470,7 +470,7 @@ Zotero.DataObjects.prototype.updateVersion = Zotero.Promise.method(function (ids obj.updateVersion(version, true); } } - }.bind(this) + }.bind(this)) ); }); @@ -487,7 +487,7 @@ Zotero.DataObjects.prototype.updateSynced = Zotero.Promise.method(function (ids, return Zotero.Utilities.Internal.forEachChunkAsync( ids, Zotero.DB.MAX_BOUND_PARAMETERS, - function* (chunk) { + Zotero.Promise.coroutine(function* (chunk) { yield Zotero.DB.queryAsync(sql + chunk.map(() => '?').join(', ') + ')', chunk); // Update the internal 'synced' property of any loaded objects for (let i = 0; i < chunk.length; i++) { @@ -497,7 +497,7 @@ Zotero.DataObjects.prototype.updateSynced = Zotero.Promise.method(function (ids, obj.updateSynced(!!synced, true); } } - }.bind(this) + }.bind(this)) ); }); diff --git a/chrome/content/zotero/xpcom/data/items.js b/chrome/content/zotero/xpcom/data/items.js index d003aac4f..b5c99444b 100644 --- a/chrome/content/zotero/xpcom/data/items.js +++ b/chrome/content/zotero/xpcom/data/items.js @@ -528,10 +528,10 @@ Zotero.Items = function() { deletedIDs = yield this.getDeleted(libraryID, true, days); if (deletedIDs.length) { - yield Zotero.Utilities.Internal.forEachChunkAsync(deletedIDs, 50, function* (chunk) { + yield Zotero.Utilities.Internal.forEachChunkAsync(deletedIDs, 50, Zotero.Promise.coroutine(function* (chunk) { yield this.erase(chunk); yield Zotero.Notifier.trigger('refresh', 'trash', libraryID); - }.bind(this)); + }.bind(this))); } if (deletedIDs.length) { diff --git a/chrome/content/zotero/xpcom/data/tags.js b/chrome/content/zotero/xpcom/data/tags.js index 137682a00..7ac2b57c6 100644 --- a/chrome/content/zotero/xpcom/data/tags.js +++ b/chrome/content/zotero/xpcom/data/tags.js @@ -191,7 +191,7 @@ Zotero.Tags = new function() { yield Zotero.Utilities.Internal.forEachChunkAsync( oldItemIDs, Zotero.DB.MAX_BOUND_PARAMETERS - 2, - function* (chunk) { + Zotero.Promise.coroutine(function* (chunk) { let placeholders = chunk.map(function () '?').join(','); // This is ugly, but it's much faster than doing replaceTag() for each item @@ -204,7 +204,7 @@ Zotero.Tags = new function() { yield Zotero.DB.queryAsync(sql, [Zotero.DB.transactionDateTime].concat(chunk)); yield Zotero.Items.reload(oldItemIDs, ['tags'], true); - } + }) ); var notifierData = {}; @@ -292,7 +292,7 @@ Zotero.Tags = new function() { yield Zotero.Utilities.Internal.forEachChunkAsync( Zotero.Utilities.arrayUnique(oldItemIDs), Zotero.DB.MAX_BOUND_PARAMETERS - 1, - function* (chunk) { + Zotero.Promise.coroutine(function* (chunk) { let placeholders = chunk.map(function () '?').join(','); sql = 'UPDATE items SET synced=0, clientDateModified=? ' @@ -300,7 +300,7 @@ Zotero.Tags = new function() { yield Zotero.DB.queryAsync(sql, [Zotero.DB.transactionDateTime].concat(chunk)); yield Zotero.Items.reload(oldItemIDs, ['primaryData', 'tags'], true); - } + }) ); }.bind(this)); diff --git a/chrome/content/zotero/xpcom/utilities_internal.js b/chrome/content/zotero/xpcom/utilities_internal.js index a507645e8..36907d998 100644 --- a/chrome/content/zotero/xpcom/utilities_internal.js +++ b/chrome/content/zotero/xpcom/utilities_internal.js @@ -35,8 +35,7 @@ Zotero.Utilities.Internal = { * * @param {Array} arr * @param {Integer} chunkSize - * @param {Function|GeneratorFunction} func - A promise-returning function or a - * promise-yielding generator + * @param {Function} func - A promise-returning function * @return {Array} The return values from the successive runs */ "forEachChunkAsync": Zotero.Promise.coroutine(function* (arr, chunkSize, func) { @@ -45,8 +44,6 @@ Zotero.Utilities.Internal = { var num = arr.length; var done = 0; - func = Zotero.Promise.coroutine(func); - do { var chunk = tmpArray.splice(0, chunkSize); done += chunk.length;