Fixed a crash that occurs when trying to add a new feed with no active accounts
This commit is contained in:
parent
e98d28c770
commit
5ded56fc28
|
@ -227,6 +227,10 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations {
|
|||
|
||||
return true
|
||||
}
|
||||
|
||||
if item.action == #selector(showAddFeedWindow(_:)) {
|
||||
return canAddNewFeed()
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
@ -591,6 +595,10 @@ private extension MainWindowController {
|
|||
|
||||
return currentTimelineViewController?.canMarkAllAsRead() ?? false
|
||||
}
|
||||
|
||||
func canAddNewFeed() -> Bool {
|
||||
return sidebarViewController?.canAddNewFeed() ?? false
|
||||
}
|
||||
|
||||
func validateToggleRead(_ item: NSValidatedUserInterfaceItem) -> Bool {
|
||||
|
||||
|
|
|
@ -345,10 +345,9 @@ protocol SidebarDelegate: class {
|
|||
// MARK: - API
|
||||
|
||||
func rebuildTreeAndRestoreSelection() {
|
||||
|
||||
let savedAccounts = treeController.rootNode.childNodes.compactMap { $0.representedObject as? Account }
|
||||
|
||||
let savedAccounts = accountNodes
|
||||
let savedSelection = selectedNodes
|
||||
|
||||
rebuildTreeAndReloadDataIfNeeded()
|
||||
restoreSelection(to: savedSelection, sendNotificationIfChanged: true)
|
||||
|
||||
|
@ -361,6 +360,11 @@ protocol SidebarDelegate: class {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
func canAddNewFeed() -> Bool {
|
||||
return !accountNodes.isEmpty
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// MARK: - NSUserInterfaceValidations
|
||||
|
@ -380,6 +384,10 @@ extension SidebarViewController: NSUserInterfaceValidations {
|
|||
|
||||
private extension SidebarViewController {
|
||||
|
||||
var accountNodes: [Account] {
|
||||
return treeController.rootNode.childNodes.compactMap { $0.representedObject as? Account }
|
||||
}
|
||||
|
||||
var selectedNodes: [Node] {
|
||||
if let nodes = outlineView.selectedItems as? [Node] {
|
||||
return nodes
|
||||
|
|
Loading…
Reference in New Issue