commit 6933f64616af3285b23ef6f0c3b77266c2c708c0
parent dd52206b37cdf098c2393580f3fd4e7f5b54807b
Author: Dan Stillman <dstillman@zotero.org>
Date: Sun, 24 May 2015 22:04:40 -0400
Fix reselection of trash after restart
Diffstat:
2 files changed, 19 insertions(+), 16 deletions(-)
diff --git a/chrome/content/zotero/xpcom/collectionTreeView.js b/chrome/content/zotero/xpcom/collectionTreeView.js
@@ -848,8 +848,8 @@ Zotero.CollectionTreeView.prototype.selectByID = Zotero.Promise.coroutine(functi
switch (type) {
case 'L':
- yield this.selectLibrary(id);
- return true;
+ var found = yield this.selectLibrary(id);
+ break;
case 'C':
var found = yield this.expandToCollection(id);
@@ -859,6 +859,10 @@ Zotero.CollectionTreeView.prototype.selectByID = Zotero.Promise.coroutine(functi
var search = yield Zotero.Searches.getAsync(id);
var found = yield this.expandLibrary(search.libraryID);
break;
+
+ case 'T':
+ var found = yield this.selectTrash(id);
+ break;
}
if (!found) {
@@ -927,29 +931,18 @@ Zotero.CollectionTreeView.prototype.selectTrash = Zotero.Promise.coroutine(funct
// Check if trash is already selected
if (this.selection.currentIndex != -1) {
- let itemGroup = this._getItemAtRow(this.selection.currentIndex);
+ let itemGroup = this.getRow(this.selection.currentIndex);
if (itemGroup.isTrash() && itemGroup.ref.libraryID == libraryID) {
this._treebox.ensureRowIsVisible(this.selection.currentIndex);
return true;
}
}
- // If in My Library and it's collapsed, open it
- if (!libraryID && !this.isContainerOpen(0)) {
- yield this.toggleOpenState(0);
- }
-
// Find library trash
for (let i = 0; i < this.rowCount; i++) {
- let itemGroup = this._getItemAtRow(i);
-
- // If group header is closed, open it
- if (itemGroup.isHeader() && itemGroup.ref.id == 'group-libraries-header'
- && !this.isContainerOpen(i)) {
- yield this.toggleOpenState(i);
- continue;
- }
+ let itemGroup = this.getRow(i);
+ // If library is closed, open it
if (itemGroup.isLibrary(true) && itemGroup.ref.libraryID == libraryID
&& !this.isContainerOpen(i)) {
yield this.toggleOpenState(i);
diff --git a/test/tests/collectionTreeViewTest.js b/test/tests/collectionTreeViewTest.js
@@ -56,6 +56,16 @@ describe("Zotero.CollectionTreeView", function() {
})
})
+ describe("#selectByID", function () {
+ it("should select the trash", function* () {
+ yield collectionsView.selectByID("T1");
+ var row = collectionsView.selection.currentIndex;
+ var treeRow = collectionsView.getRow(row);
+ assert.ok(treeRow.isTrash());
+ assert.equal(treeRow.ref.libraryID, Zotero.Libraries.userLibraryID);
+ })
+ })
+
describe("#notify()", function () {
it("should select a new collection", function* () {
// Create collection