diff --git a/chrome/content/zotero/xpcom/collectionTreeView.js b/chrome/content/zotero/xpcom/collectionTreeView.js index f79a2f84c..a918ef161 100644 --- a/chrome/content/zotero/xpcom/collectionTreeView.js +++ b/chrome/content/zotero/xpcom/collectionTreeView.js @@ -34,12 +34,8 @@ Zotero.CollectionTreeView = function() { this._treebox = null; - this.refresh(); - this.itemToSelect = null; - this._highlightedRows = {}; - this._unregisterID = Zotero.Notifier.registerObserver(this, ['collection', 'search']); } @@ -71,6 +67,8 @@ Zotero.CollectionTreeView.prototype.setTree = function(treebox) } }, false); + this.refresh(); + //select Library this.selection.select(0); } @@ -81,7 +79,9 @@ Zotero.CollectionTreeView.prototype.setTree = function(treebox) */ Zotero.CollectionTreeView.prototype.refresh = function() { - this._dataItems = new Array(); + this.selection.clearSelection(); + var oldCount = this.rowCount; + this._dataItems = []; this.rowCount = 0; this._showItem(new Zotero.ItemGroup('library',null),0,1); @@ -90,10 +90,19 @@ Zotero.CollectionTreeView.prototype.refresh = function() this._showItem(new Zotero.ItemGroup('collection',newRows[i]), 0, this._dataItems.length); //itemgroup ref, level, beforeRow var savedSearches = Zotero.Searches.getAll(); - for(var i = 0; i < savedSearches.length; i++) - this._showItem(new Zotero.ItemGroup('search',savedSearches[i]), 0, this._dataItems.length); //itemgroup ref, level, beforeRow + if (savedSearches) { + for (var i=0; i