Fix hang in collectionsTreeView::selectWait() if row is already selected
This commit is contained in:
parent
43762248a4
commit
cbbdebc5b7
6 changed files with 19 additions and 4 deletions
|
@ -262,6 +262,9 @@ Zotero.CollectionTreeView.prototype.selectWait = Zotero.Promise.method(function
|
||||||
this.selection.select(row);
|
this.selection.select(row);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (this.selection.currentIndex == row) {
|
||||||
|
return;
|
||||||
|
};
|
||||||
var deferred = Zotero.Promise.defer();
|
var deferred = Zotero.Promise.defer();
|
||||||
this.addEventListener('select', () => deferred.resolve());
|
this.addEventListener('select', () => deferred.resolve());
|
||||||
this.selection.select(row);
|
this.selection.select(row);
|
||||||
|
|
|
@ -68,7 +68,7 @@ Zotero.ItemTreeView.prototype.type = 'item';
|
||||||
Zotero.ItemTreeView.prototype.setTree = Zotero.serial(Zotero.Promise.coroutine(function* (treebox)
|
Zotero.ItemTreeView.prototype.setTree = Zotero.serial(Zotero.Promise.coroutine(function* (treebox)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
Zotero.debug("Setting tree for items view " + this.id);
|
Zotero.debug("Setting tree for " + this.collectionTreeRow.id + " items view " + this.id);
|
||||||
var start = Date.now();
|
var start = Date.now();
|
||||||
// Try to set the window document if not yet set
|
// Try to set the window document if not yet set
|
||||||
if (treebox && !this._ownerDocument) {
|
if (treebox && !this._ownerDocument) {
|
||||||
|
|
|
@ -82,6 +82,7 @@ Zotero.LibraryTreeView.prototype = {
|
||||||
* @return {Integer}
|
* @return {Integer}
|
||||||
*/
|
*/
|
||||||
getRowByID: function (id) {
|
getRowByID: function (id) {
|
||||||
|
// FIXME: Should work for itemIDs too
|
||||||
var type = id[0];
|
var type = id[0];
|
||||||
id = ('' + id).substr(1);
|
id = ('' + id).substr(1);
|
||||||
return this._rowMap[type + id];
|
return this._rowMap[type + id];
|
||||||
|
|
|
@ -41,6 +41,7 @@ function loadBrowserWindow() {
|
||||||
*/
|
*/
|
||||||
var loadZoteroPane = Zotero.Promise.coroutine(function* () {
|
var loadZoteroPane = Zotero.Promise.coroutine(function* () {
|
||||||
var win = yield loadBrowserWindow();
|
var win = yield loadBrowserWindow();
|
||||||
|
Zotero.Prefs.clear('lastViewedFolder');
|
||||||
win.ZoteroOverlay.toggleDisplay(true);
|
win.ZoteroOverlay.toggleDisplay(true);
|
||||||
|
|
||||||
// Hack to wait for pane load to finish. This is the same hack
|
// Hack to wait for pane load to finish. This is the same hack
|
||||||
|
|
|
@ -49,7 +49,7 @@ describe("Zotero.CollectionTreeView", function() {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe("#selectByID", function () {
|
describe("#selectByID()", function () {
|
||||||
it("should select the trash", function* () {
|
it("should select the trash", function* () {
|
||||||
yield collectionsView.selectByID("T1");
|
yield collectionsView.selectByID("T1");
|
||||||
var row = collectionsView.selection.currentIndex;
|
var row = collectionsView.selection.currentIndex;
|
||||||
|
@ -59,6 +59,15 @@ describe("Zotero.CollectionTreeView", function() {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe("#selectWait()", function () {
|
||||||
|
it("shouldn't hang if row is already selected", function* () {
|
||||||
|
var row = collectionsView.getRowByID("T" + Zotero.Libraries.userLibraryID);
|
||||||
|
collectionsView.selection.select(row);
|
||||||
|
yield Zotero.Promise.delay(50);
|
||||||
|
yield collectionsView.selectWait(row);
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe("#notify()", function () {
|
describe("#notify()", function () {
|
||||||
it("should select a new collection", function* () {
|
it("should select a new collection", function* () {
|
||||||
// Create collection
|
// Create collection
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
describe("Zotero.Items", function () {
|
describe("Zotero.Items", function () {
|
||||||
var win, collectionsView;
|
var win, collectionsView, zp;
|
||||||
|
|
||||||
before(function* () {
|
before(function* () {
|
||||||
win = yield loadZoteroPane();
|
win = yield loadZoteroPane();
|
||||||
collectionsView = win.ZoteroPane.collectionsView;
|
collectionsView = win.ZoteroPane.collectionsView;
|
||||||
|
zp = win.ZoteroPane;
|
||||||
})
|
})
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
return selectLibrary(win);
|
return selectLibrary(win);
|
||||||
|
@ -36,7 +37,7 @@ describe("Zotero.Items", function () {
|
||||||
assert.isFalse(yield Zotero.Items.getAsync(id1));
|
assert.isFalse(yield Zotero.Items.getAsync(id1));
|
||||||
assert.isFalse(yield Zotero.Items.getAsync(id2));
|
assert.isFalse(yield Zotero.Items.getAsync(id2));
|
||||||
assert.isFalse(yield Zotero.Items.getAsync(id3));
|
assert.isFalse(yield Zotero.Items.getAsync(id3));
|
||||||
assert.equal(win.ZoteroPane.itemsView.rowCount, 0);
|
assert.equal(zp.itemsView.rowCount, 0);
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue