Fix #1054, UI breakage after unsubscribing from feed
This commit is contained in:
parent
9e6565fe00
commit
622530e889
4 changed files with 32 additions and 17 deletions
|
@ -372,6 +372,7 @@ Zotero.CollectionTreeView.prototype.notify = Zotero.Promise.coroutine(function*
|
|||
|
||||
if (action == 'delete') {
|
||||
var selectedIndex = this.selection.count ? this.selection.currentIndex : 0;
|
||||
let refreshFeeds = false;
|
||||
|
||||
// Since a delete involves shifting of rows, we have to do it in reverse order
|
||||
let rows = [];
|
||||
|
@ -399,6 +400,10 @@ Zotero.CollectionTreeView.prototype.notify = Zotero.Promise.coroutine(function*
|
|||
row++;
|
||||
}
|
||||
while (row < this.rowCount && this.getLevel(row) > level);
|
||||
|
||||
if (type == 'feed') {
|
||||
refreshFeeds = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -411,6 +416,18 @@ Zotero.CollectionTreeView.prototype.notify = Zotero.Promise.coroutine(function*
|
|||
this._removeRow(row);
|
||||
}
|
||||
|
||||
// If a feed was removed and there are no more, remove Feeds header
|
||||
if (refreshFeeds && !Zotero.Feeds.haveFeeds()) {
|
||||
for (let i = 0; i < this._rows.length; i++) {
|
||||
let row = this._rows[i];
|
||||
if (row.ref.id == 'feed-libraries-header') {
|
||||
this._removeRow(i);
|
||||
this._removeRow(i - 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this._refreshRowMap();
|
||||
}
|
||||
|
||||
|
@ -1186,26 +1203,15 @@ Zotero.CollectionTreeView.prototype.deleteSelection = Zotero.Promise.coroutine(f
|
|||
yield treeRow.ref.eraseTx({
|
||||
deleteItems: true
|
||||
});
|
||||
}
|
||||
if (treeRow.isCollection() || treeRow.isFeed()) {
|
||||
yield treeRow.ref.erase(deleteItems);
|
||||
if (treeRow.isFeed()) {
|
||||
refreshFeeds = true;
|
||||
}
|
||||
}
|
||||
else if (treeRow.isSearch()) {
|
||||
yield Zotero.Searches.erase(treeRow.ref.id);
|
||||
}
|
||||
}
|
||||
//this._treebox.endUpdateBatch();
|
||||
|
||||
if (end.value < this.rowCount) {
|
||||
var row = this.getRow(end.value);
|
||||
if (row.isSeparator()) {
|
||||
return;
|
||||
}
|
||||
this.selection.select(end.value);
|
||||
}
|
||||
else {
|
||||
this.selection.select(this.rowCount-1);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
|
|
@ -61,8 +61,8 @@ Zotero.Feed = function(params = {}) {
|
|||
// Return a proxy so that we can disable the object once it's deleted
|
||||
return new Proxy(this, {
|
||||
get: function(obj, prop) {
|
||||
if (obj._disabled && !(prop == 'libraryID' || prop == 'id')) {
|
||||
throw new Error("Feed (" + obj.libraryID + ") has been disabled");
|
||||
if (obj._disabled && !(prop == 'libraryID' || prop == 'id' || prop == 'treeViewID')) {
|
||||
throw new Error("Feed " + obj.libraryID + " has been disabled");
|
||||
}
|
||||
return obj[prop];
|
||||
}
|
||||
|
|
|
@ -1905,7 +1905,7 @@ var ZoteroPane = new function()
|
|||
"", "", "", {}
|
||||
);
|
||||
if (index == 0) {
|
||||
this.collectionsView.deleteSelection(deleteItems);
|
||||
return this.collectionsView.deleteSelection(deleteItems);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -383,6 +383,15 @@ describe("Zotero.CollectionTreeView", function() {
|
|||
assert.equal(cv.getSelectedLibraryID(), feed.id);
|
||||
})
|
||||
|
||||
it("should remove deleted feed", function* () {
|
||||
var feed = yield createFeed();
|
||||
yield cv.selectLibrary(feed.libraryID);
|
||||
waitForDialog();
|
||||
var id = feed.treeViewID;
|
||||
yield win.ZoteroPane.deleteSelectedCollection();
|
||||
assert.isFalse(cv.getRowIndexByID(id))
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
describe("#drop()", function () {
|
||||
|
|
Loading…
Reference in a new issue