From 8c7c2425f66fcf132ed865d24a2b909ca371e8af Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Fri, 27 May 2011 21:33:45 +0000 Subject: [PATCH] Prevent excessive item saving when dragging a child note to another parent (since r8762) by triggering queued notifications asynchronously --- chrome/content/zotero/xpcom/itemTreeView.js | 7 +++++-- chrome/content/zotero/xpcom/zotero.js | 6 +++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/chrome/content/zotero/xpcom/itemTreeView.js b/chrome/content/zotero/xpcom/itemTreeView.js index 7931d8f6a..ed9feebc4 100644 --- a/chrome/content/zotero/xpcom/itemTreeView.js +++ b/chrome/content/zotero/xpcom/itemTreeView.js @@ -386,6 +386,7 @@ Zotero.ItemTreeView.prototype.notify = function(action, type, ids, extraData) else if (!quicksearch || quicksearch.value == '') { var items = Zotero.Items.get(ids); + for each(var item in items) { var id = item.id; @@ -401,9 +402,11 @@ Zotero.ItemTreeView.prototype.notify = function(action, type, ids, extraData) { this.toggleOpenState(row); this.toggleOpenState(row); + sort = id; } // If item moved from top-level to under another item, - // remove the old row + // remove the old row -- the container refresh above + // takes care of adding the new row else if (!this.isContainer(row) && parentIndex == -1 && sourceItemID) { @@ -418,7 +421,7 @@ Zotero.ItemTreeView.prototype.notify = function(action, type, ids, extraData) this._treebox.rowCountChanged(this.rowCount-1, 1); sort = id; } - // If not moved from under one item to another + // If not moved from under one item to another, resort the row else if (!(sourceItemID && parentIndex != -1 && this._itemRowMap[sourceItemID] != parentIndex)) { sort = id; } diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js index 161cd1b50..3dc9054b1 100644 --- a/chrome/content/zotero/xpcom/zotero.js +++ b/chrome/content/zotero/xpcom/zotero.js @@ -466,7 +466,11 @@ var Zotero = new function(){ // Add notifier queue callbacks to the DB layer Zotero.DB.addCallback('begin', Zotero.Notifier.begin); - Zotero.DB.addCallback('commit', Zotero.Notifier.commit); + Zotero.DB.addCallback('commit', function () { + setTimeout(function () { + Zotero.Notifier.commit(); + }, 1) + }); Zotero.DB.addCallback('rollback', Zotero.Notifier.reset); Zotero.Fulltext.init();