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.
This commit is contained in:
Simon Kornblith 2012-07-22 15:55:40 -04:00
parent 445b95d60d
commit 7f732f56df
3 changed files with 18 additions and 4 deletions

View file

@ -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;
}
/*

View file

@ -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;
}

View file

@ -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();
}
}
}