Fix "this.selection is undefined" switching away from loading collection

This commit is contained in:
Dan Stillman 2016-04-11 02:29:25 -04:00
parent 7c3a134107
commit bb4db297c4

View file

@ -1319,11 +1319,15 @@ var ZoteroPane = new function()
});
yield deferred.promise;
var selectedItems = this.itemsView.getSelectedItems();
if (!this.itemsView || !this.itemsView.selection) {
Zotero.debug("Items view not available in itemSelected", 2);
return false;
}
// Check if selection has actually changed. The onselect event that calls this
// can be called in various situations where the selection didn't actually change,
// such as whenever selectEventsSuppressed is set to false.
var selectedItems = this.itemsView.getSelectedItems();
var ids = selectedItems.map(item => item.id);
ids.sort();
if (ids.length && Zotero.Utilities.arrayEquals(_lastSelectedItems, ids)) {
@ -1331,11 +1335,6 @@ var ZoteroPane = new function()
}
_lastSelectedItems = ids;
if (!this.itemsView) {
Zotero.debug("Items view not available in itemSelected", 2);
return false;
}
// Display restore/delete buttons depending on context
if (this.itemsView.selection.count) {
document.getElementById('zotero-item-pane-top-buttons-trash').hidden