CollectionTreeView::selectLibrary() doesn't need to be async
This commit is contained in:
parent
16d79c5cbf
commit
6328d1f39b
|
@ -707,7 +707,7 @@ Zotero.CollectionTreeView.prototype.collapseLibrary = Zotero.Promise.coroutine(f
|
||||||
//this._treebox.endUpdateBatch();
|
//this._treebox.endUpdateBatch();
|
||||||
|
|
||||||
// Select the collapsed library
|
// 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
|
* @param {Integer} libraryID Library to select
|
||||||
*/
|
*/
|
||||||
Zotero.CollectionTreeView.prototype.selectLibrary = Zotero.Promise.coroutine(function* (libraryID) {
|
Zotero.CollectionTreeView.prototype.selectLibrary = function (libraryID) {
|
||||||
if (Zotero.suppressUIUpdates) {
|
if (Zotero.suppressUIUpdates) {
|
||||||
Zotero.debug("UI updates suppressed -- not changing library selection");
|
Zotero.debug("UI updates suppressed -- not changing library selection");
|
||||||
return false;
|
return false;
|
||||||
|
@ -779,7 +779,7 @@ Zotero.CollectionTreeView.prototype.selectLibrary = Zotero.Promise.coroutine(fun
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
});
|
}
|
||||||
|
|
||||||
|
|
||||||
Zotero.CollectionTreeView.prototype.selectTrash = function (libraryID) {
|
Zotero.CollectionTreeView.prototype.selectTrash = function (libraryID) {
|
||||||
|
|
|
@ -2014,19 +2014,7 @@ var ZoteroPane = new function()
|
||||||
var self = this;
|
var self = this;
|
||||||
var deferred = Zotero.Promise.defer();
|
var deferred = Zotero.Promise.defer();
|
||||||
this.collectionsView.addEventListener('load', function () {
|
this.collectionsView.addEventListener('load', function () {
|
||||||
Zotero.spawn(function* () {
|
try {
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
self.addEventListener('itemsLoaded', function () {
|
self.addEventListener('itemsLoaded', function () {
|
||||||
Zotero.spawn(function* () {
|
Zotero.spawn(function* () {
|
||||||
var selected = yield self.itemsView.selectItem(itemID, expand);
|
var selected = yield self.itemsView.selectItem(itemID, expand);
|
||||||
|
@ -2037,7 +2025,7 @@ var ZoteroPane = new function()
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Zotero.debug("Item was not selected; switching to library");
|
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);
|
yield self.itemsView.selectItem(itemID, expand);
|
||||||
}
|
}
|
||||||
|
@ -2047,10 +2035,22 @@ var ZoteroPane = new function()
|
||||||
deferred.reject(e);
|
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);
|
deferred.reject(e);
|
||||||
});
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// open Zotero pane
|
// open Zotero pane
|
||||||
|
|
|
@ -12,14 +12,14 @@ describe("Zotero.CollectionTreeView", function() {
|
||||||
|
|
||||||
// Select library
|
// Select library
|
||||||
// TODO: Add a selectCollection() function and select a collection instead
|
// TODO: Add a selectCollection() function and select a collection instead
|
||||||
var resetSelection = Zotero.Promise.coroutine(function* () {
|
var resetSelection = function () {
|
||||||
yield collectionsView.selectLibrary(Zotero.Libraries.userLibraryID);
|
collectionsView.selectLibrary(Zotero.Libraries.userLibraryID);
|
||||||
assert.equal(collectionsView.getSelectedLibraryID(), Zotero.Libraries.userLibraryID);
|
assert.equal(collectionsView.getSelectedLibraryID(), Zotero.Libraries.userLibraryID);
|
||||||
});
|
}
|
||||||
|
|
||||||
describe("#notify()", function () {
|
describe("#notify()", function () {
|
||||||
it("should select a new collection", function* () {
|
it("should select a new collection", function* () {
|
||||||
yield resetSelection();
|
resetSelection();
|
||||||
|
|
||||||
// Create collection
|
// Create collection
|
||||||
var collection = new Zotero.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* () {
|
it("shouldn't select a new collection if skipNotifier is passed", function* () {
|
||||||
yield resetSelection();
|
resetSelection();
|
||||||
|
|
||||||
// Create collection with skipNotifier flag
|
// Create collection with skipNotifier flag
|
||||||
var collection = new Zotero.Collection;
|
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* () {
|
it("shouldn't select a new collection if skipSelect is passed", function* () {
|
||||||
yield resetSelection();
|
resetSelection();
|
||||||
|
|
||||||
// Create collection with skipSelect flag
|
// Create collection with skipSelect flag
|
||||||
var collection = new Zotero.Collection;
|
var collection = new Zotero.Collection;
|
||||||
|
@ -68,7 +68,7 @@ describe("Zotero.CollectionTreeView", function() {
|
||||||
collection = yield Zotero.Collections.getAsync(id);
|
collection = yield Zotero.Collections.getAsync(id);
|
||||||
yield Zotero.Promise.delay(100);
|
yield Zotero.Promise.delay(100);
|
||||||
|
|
||||||
yield resetSelection();
|
resetSelection();
|
||||||
|
|
||||||
collection.name = "No select on modify 2";
|
collection.name = "No select on modify 2";
|
||||||
yield collection.save();
|
yield collection.save();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user