commit 6650646cbabe1bd59696a66ba73e2972d4298729
parent 2029d2aebd87a9a6fed4f15ae2de24c03cdd8d04
Author: Dan Stillman <dstillman@zotero.org>
Date: Sat, 8 Aug 2009 18:12:52 +0000
- Speed up collection-item notifier triggers from r4863
- Add Zotero.wait() after every 25 collection-item inserts
Diffstat:
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/chrome/content/zotero/xpcom/data/collection.js b/chrome/content/zotero/xpcom/data/collection.js
@@ -665,6 +665,8 @@ Zotero.Collection.prototype.addItems = function(itemIDs) {
sql = "INSERT OR IGNORE INTO collectionItems VALUES (?,?,?)";
var insertStatement = Zotero.DB.getStatement(sql);
+ var notifierPairs = [];
+
for (var i=0; i<itemIDs.length; i++) {
var itemID = itemIDs[i];
if (current && current.indexOf(itemID) != -1) {
@@ -700,7 +702,11 @@ Zotero.Collection.prototype.addItems = function(itemIDs) {
throw (e + ' [ERROR: ' + Zotero.DB.getLastErrorString() + ']');
}
- Zotero.Notifier.trigger('add', 'collection-item', this.id + '-' + itemID);
+ notifierPairs.push(this.id + '-' + itemID);
+
+ if ((i % 25) == 0) {
+ Zotero.wait();
+ }
}
sql = "UPDATE collections SET dateModified=?, clientDateModified=? WHERE collectionID=?";
@@ -709,6 +715,7 @@ Zotero.Collection.prototype.addItems = function(itemIDs) {
Zotero.DB.commitTransaction();
Zotero.Collections.reload(this.id);
+ Zotero.Notifier.trigger('add', 'collection-item', notifierPairs);
}