www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 7f732f56df4074a0af7a685481e570cbb3f7a5c4
parent 445b95d60daab908f21a563a153047018056d0a1
Author: Simon Kornblith <simon@simonster.com>
Date:   Sun, 22 Jul 2012 15:55:40 -0400

Don't refresh item list upon tag selector actions unless the action changes the item list.

This speeds up adding/deleting tags a little bit, but unfortunately updating the tag selector itself is still quite slow.

Diffstat:
Mchrome/content/zotero/xpcom/collectionTreeView.js | 7++++++-
Mchrome/content/zotero/xpcom/itemTreeView.js | 7+++++--
Mchrome/content/zotero/zoteroPane.js | 8+++++++-
3 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/chrome/content/zotero/xpcom/collectionTreeView.js b/chrome/content/zotero/xpcom/collectionTreeView.js @@ -2180,14 +2180,19 @@ Zotero.ItemGroup.prototype.getChildTags = function() { Zotero.ItemGroup.prototype.setSearch = function(searchText) { + if(searchText === this.searchText) return false; Zotero.ItemGroupCache.clear(); this.searchText = searchText; + return true; } Zotero.ItemGroup.prototype.setTags = function(tags) { + if((!tags || Zotero.Utilities.isEmpty(tags)) + && (!this.tags || Zotero.Utilities.isEmpty(this.tags))) return false; Zotero.ItemGroupCache.clear(); - this.tags = tags; + this.tags = Zotero.Utilities.deepCopy(tags); + return true; } /* diff --git a/chrome/content/zotero/xpcom/itemTreeView.js b/chrome/content/zotero/xpcom/itemTreeView.js @@ -1703,16 +1703,18 @@ Zotero.ItemTreeView.prototype.setFilter = function(type, data) { var savedOpenState = this.saveOpenState(); var savedFirstRow = this.saveFirstRow(); + var isDirty; switch (type) { case 'search': - this._itemGroup.setSearch(data); + isDirty = this._itemGroup.setSearch(data); break; case 'tags': - this._itemGroup.setTags(data); + isDirty = this._itemGroup.setTags(data); break; default: throw ('Invalid filter type in setFilter'); } + if(!isDirty) return false; var oldCount = this.rowCount; this.refresh(); @@ -1727,6 +1729,7 @@ Zotero.ItemTreeView.prototype.setFilter = function(type, data) { //Zotero.debug('Running callbacks in itemTreeView.setFilter()', 4); this._runCallbacks(); + return true; } diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js @@ -999,7 +999,13 @@ var ZoteroPane = new function() */ function updateTagFilter(){ if (this.itemsView) { - this.itemsView.setFilter('tags', getTagSelection()); + // If setFilter returns false, that means the tags didn't change. In that + // case, callbacks don't get called, so we need to update tags in the tag + // selector on our own. + if(!this.itemsView.setFilter('tags', getTagSelection())) { + var tagSelector = document.getElementById('zotero-tag-selector'); + tagSelector.refresh(); + } } }