mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2025-02-01 11:36:56 +01:00
Merge pull request #648 from philviso/FixedAddNewFeedCrash
Fixed a crash that occurs when trying to add a new feed with no active accounts
This commit is contained in:
commit
d42398b028
@ -227,6 +227,14 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations {
|
|||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if item.action == #selector(showAddFeedWindow(_:)) {
|
||||||
|
return canAddNewFeed()
|
||||||
|
}
|
||||||
|
|
||||||
|
if item.action == #selector(showAddFolderWindow(_:)) {
|
||||||
|
return canAddNewFolder()
|
||||||
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@ -591,6 +599,14 @@ private extension MainWindowController {
|
|||||||
|
|
||||||
return currentTimelineViewController?.canMarkAllAsRead() ?? false
|
return currentTimelineViewController?.canMarkAllAsRead() ?? false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func canAddNewFeed() -> Bool {
|
||||||
|
return sidebarViewController?.canAddNewFeed() ?? false
|
||||||
|
}
|
||||||
|
|
||||||
|
func canAddNewFolder() -> Bool {
|
||||||
|
return sidebarViewController?.canAddNewFolder() ?? false
|
||||||
|
}
|
||||||
|
|
||||||
func validateToggleRead(_ item: NSValidatedUserInterfaceItem) -> Bool {
|
func validateToggleRead(_ item: NSValidatedUserInterfaceItem) -> Bool {
|
||||||
|
|
||||||
|
@ -345,10 +345,9 @@ protocol SidebarDelegate: class {
|
|||||||
// MARK: - API
|
// MARK: - API
|
||||||
|
|
||||||
func rebuildTreeAndRestoreSelection() {
|
func rebuildTreeAndRestoreSelection() {
|
||||||
|
let savedAccounts = accountNodes
|
||||||
let savedAccounts = treeController.rootNode.childNodes.compactMap { $0.representedObject as? Account }
|
|
||||||
|
|
||||||
let savedSelection = selectedNodes
|
let savedSelection = selectedNodes
|
||||||
|
|
||||||
rebuildTreeAndReloadDataIfNeeded()
|
rebuildTreeAndReloadDataIfNeeded()
|
||||||
restoreSelection(to: savedSelection, sendNotificationIfChanged: true)
|
restoreSelection(to: savedSelection, sendNotificationIfChanged: true)
|
||||||
|
|
||||||
@ -361,6 +360,15 @@ protocol SidebarDelegate: class {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func canAddNewFeed() -> Bool {
|
||||||
|
return !accountNodes.isEmpty
|
||||||
|
}
|
||||||
|
|
||||||
|
func canAddNewFolder() -> Bool {
|
||||||
|
return !accountNodes.isEmpty
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - NSUserInterfaceValidations
|
// MARK: - NSUserInterfaceValidations
|
||||||
@ -380,6 +388,10 @@ extension SidebarViewController: NSUserInterfaceValidations {
|
|||||||
|
|
||||||
private extension SidebarViewController {
|
private extension SidebarViewController {
|
||||||
|
|
||||||
|
var accountNodes: [Account] {
|
||||||
|
return treeController.rootNode.childNodes.compactMap { $0.representedObject as? Account }
|
||||||
|
}
|
||||||
|
|
||||||
var selectedNodes: [Node] {
|
var selectedNodes: [Node] {
|
||||||
if let nodes = outlineView.selectedItems as? [Node] {
|
if let nodes = outlineView.selectedItems as? [Node] {
|
||||||
return nodes
|
return nodes
|
||||||
|
Loading…
x
Reference in New Issue
Block a user