CollectionTreeView::selectLibrary() doesn't need to be async
This commit is contained in:
parent
16d79c5cbf
commit
6328d1f39b
3 changed files with 27 additions and 27 deletions
|
@ -707,7 +707,7 @@ Zotero.CollectionTreeView.prototype.collapseLibrary = Zotero.Promise.coroutine(f
|
|||
//this._treebox.endUpdateBatch();
|
||||
|
||||
// Select the collapsed library
|
||||
yield this.selectLibrary(selectedLibraryID);
|
||||
this.selectLibrary(selectedLibraryID);
|
||||
});
|
||||
|
||||
|
||||
|
@ -746,7 +746,7 @@ Zotero.CollectionTreeView.prototype.expandToCollection = Zotero.Promise.coroutin
|
|||
/**
|
||||
* @param {Integer} libraryID Library to select
|
||||
*/
|
||||
Zotero.CollectionTreeView.prototype.selectLibrary = Zotero.Promise.coroutine(function* (libraryID) {
|
||||
Zotero.CollectionTreeView.prototype.selectLibrary = function (libraryID) {
|
||||
if (Zotero.suppressUIUpdates) {
|
||||
Zotero.debug("UI updates suppressed -- not changing library selection");
|
||||
return false;
|
||||
|
@ -779,7 +779,7 @@ Zotero.CollectionTreeView.prototype.selectLibrary = Zotero.Promise.coroutine(fun
|
|||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Zotero.CollectionTreeView.prototype.selectTrash = function (libraryID) {
|
||||
|
|
|
@ -2014,19 +2014,7 @@ var ZoteroPane = new function()
|
|||
var self = this;
|
||||
var deferred = Zotero.Promise.defer();
|
||||
this.collectionsView.addEventListener('load', function () {
|
||||
Zotero.spawn(function* () {
|
||||
var currentLibraryID = self.getSelectedLibraryID();
|
||||
// If in a different library
|
||||
if (item.libraryID != currentLibraryID) {
|
||||
Zotero.debug("Library ID differs; switching library");
|
||||
yield self.collectionsView.selectLibrary(item.libraryID);
|
||||
}
|
||||
// Force switch to library view
|
||||
else if (!self.collectionsView.selectedTreeRow.isLibrary() && inLibrary) {
|
||||
Zotero.debug("Told to select in library; switching to library");
|
||||
yield self.collectionsView.selectLibrary(item.libraryID);
|
||||
}
|
||||
|
||||
try {
|
||||
self.addEventListener('itemsLoaded', function () {
|
||||
Zotero.spawn(function* () {
|
||||
var selected = yield self.itemsView.selectItem(itemID, expand);
|
||||
|
@ -2037,7 +2025,7 @@ var ZoteroPane = new function()
|
|||
}
|
||||
else {
|
||||
Zotero.debug("Item was not selected; switching to library");
|
||||
yield self.collectionsView.selectLibrary(item.libraryID);
|
||||
self.collectionsView.selectLibrary(item.libraryID);
|
||||
}
|
||||
yield self.itemsView.selectItem(itemID, expand);
|
||||
}
|
||||
|
@ -2047,10 +2035,22 @@ var ZoteroPane = new function()
|
|||
deferred.reject(e);
|
||||
});
|
||||
});
|
||||
})
|
||||
.catch(function(e) {
|
||||
|
||||
var currentLibraryID = self.getSelectedLibraryID();
|
||||
// If in a different library
|
||||
if (item.libraryID != currentLibraryID) {
|
||||
Zotero.debug("Library ID differs; switching library");
|
||||
self.collectionsView.selectLibrary(item.libraryID);
|
||||
}
|
||||
// Force switch to library view
|
||||
else if (!self.collectionsView.selectedTreeRow.isLibrary() && inLibrary) {
|
||||
Zotero.debug("Told to select in library; switching to library");
|
||||
self.collectionsView.selectLibrary(item.libraryID);
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
deferred.reject(e);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// open Zotero pane
|
||||
|
|
|
@ -12,14 +12,14 @@ describe("Zotero.CollectionTreeView", function() {
|
|||
|
||||
// Select library
|
||||
// TODO: Add a selectCollection() function and select a collection instead
|
||||
var resetSelection = Zotero.Promise.coroutine(function* () {
|
||||
yield collectionsView.selectLibrary(Zotero.Libraries.userLibraryID);
|
||||
var resetSelection = function () {
|
||||
collectionsView.selectLibrary(Zotero.Libraries.userLibraryID);
|
||||
assert.equal(collectionsView.getSelectedLibraryID(), Zotero.Libraries.userLibraryID);
|
||||
});
|
||||
}
|
||||
|
||||
describe("#notify()", function () {
|
||||
it("should select a new collection", function* () {
|
||||
yield resetSelection();
|
||||
resetSelection();
|
||||
|
||||
// Create collection
|
||||
var collection = new Zotero.Collection;
|
||||
|
@ -33,7 +33,7 @@ describe("Zotero.CollectionTreeView", function() {
|
|||
});
|
||||
|
||||
it("shouldn't select a new collection if skipNotifier is passed", function* () {
|
||||
yield resetSelection();
|
||||
resetSelection();
|
||||
|
||||
// Create collection with skipNotifier flag
|
||||
var collection = new Zotero.Collection;
|
||||
|
@ -47,7 +47,7 @@ describe("Zotero.CollectionTreeView", function() {
|
|||
});
|
||||
|
||||
it("shouldn't select a new collection if skipSelect is passed", function* () {
|
||||
yield resetSelection();
|
||||
resetSelection();
|
||||
|
||||
// Create collection with skipSelect flag
|
||||
var collection = new Zotero.Collection;
|
||||
|
@ -68,7 +68,7 @@ describe("Zotero.CollectionTreeView", function() {
|
|||
collection = yield Zotero.Collections.getAsync(id);
|
||||
yield Zotero.Promise.delay(100);
|
||||
|
||||
yield resetSelection();
|
||||
resetSelection();
|
||||
|
||||
collection.name = "No select on modify 2";
|
||||
yield collection.save();
|
||||
|
|
Loading…
Add table
Reference in a new issue