Update sidebar when adding a folder.

This commit is contained in:
Brent Simmons 2017-10-19 13:27:59 -07:00
parent 3812c216b2
commit aca8acea7c
4 changed files with 16 additions and 10 deletions

View File

@ -14,14 +14,17 @@ import Account
@objc class SidebarViewController: NSViewController, NSOutlineViewDelegate, NSOutlineViewDataSource { @objc class SidebarViewController: NSViewController, NSOutlineViewDelegate, NSOutlineViewDataSource {
@IBOutlet var outlineView: NSOutlineView! @IBOutlet var outlineView: NSOutlineView!
let treeController = TreeController(delegate: SidebarTreeControllerDelegate()) let treeControllerDelegate = SidebarTreeControllerDelegate()
lazy var treeController: TreeController = {
TreeController(delegate: treeControllerDelegate)
}()
//MARK: NSViewController //MARK: NSViewController
override func viewDidLoad() { override func viewDidLoad() {
NotificationCenter.default.addObserver(self, selector: #selector(unreadCountDidChange(_:)), name: .UnreadCountDidChange, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(unreadCountDidChange(_:)), name: .UnreadCountDidChange, object: nil)
// NotificationCenter.default.addObserver(self, selector: #selector(folderChildrenDidChange(_:)), name: NSNotification.Name(rawValue: FolderChildrenDidChangeNotification), object: nil) NotificationCenter.default.addObserver(self, selector: #selector(containerChildrenDidChange(_:)), name: .ChildrenDidChange, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(userDidAddFeed(_:)), name: UserDidAddFeedNotification, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(userDidAddFeed(_:)), name: UserDidAddFeedNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(batchUpdateDidFinish(_:)), name: .BatchUpdateDidFinish, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(batchUpdateDidFinish(_:)), name: .BatchUpdateDidFinish, object: nil)
@ -38,7 +41,7 @@ import Account
let _ = configureCellsForRepresentedObject(representedObject as AnyObject) let _ = configureCellsForRepresentedObject(representedObject as AnyObject)
} }
@objc dynamic func folderChildrenDidChange(_ note: Notification) { @objc dynamic func containerChildrenDidChange(_ note: Notification) {
rebuildTreeAndReloadDataIfNeeded() rebuildTreeAndReloadDataIfNeeded()
} }

View File

@ -192,6 +192,7 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
children += [folder] children += [folder]
dirty = true dirty = true
postChildrenDidChangeNotification()
return folder return folder
} }

View File

@ -17,7 +17,7 @@ public typealias NodeVisitBlock = (_ : Node) -> Void
public final class TreeController { public final class TreeController {
fileprivate weak var delegate: TreeControllerDelegate? private weak var delegate: TreeControllerDelegate?
public let rootNode: Node public let rootNode: Node
public init(delegate: TreeControllerDelegate, rootNode: Node) { public init(delegate: TreeControllerDelegate, rootNode: Node) {

View File

@ -6,16 +6,18 @@
</editor> --> </editor> -->
<title>ToDo</title> <title>ToDo</title>
<dateCreated>Tue, 12 Sep 2017 20:15:17 GMT</dateCreated> <dateCreated>Tue, 12 Sep 2017 20:15:17 GMT</dateCreated>
<expansionState>0,12,20,23,24,27,31,37,45,46,48,63,68</expansionState> <expansionState>0,14,22,25,26,29,33,39,47,48,50,65,70</expansionState>
<vertScrollState>0</vertScrollState> <vertScrollState>0</vertScrollState>
<windowTop>581</windowTop> <windowTop>632</windowTop>
<windowLeft>54</windowLeft> <windowLeft>48</windowLeft>
<windowRight>786</windowRight> <windowRight>780</windowRight>
<windowBottom>1340</windowBottom> <windowBottom>1391</windowBottom>
</head> </head>
<body> <body>
<outline text="App"> <outline text="App">
<outline text="Make adding a Folder work — the sidebar should update"/> <outline text="Make New Folder a default toolbar item"/>
<outline text="Bug: sidebar tree controller duplicates items after adding a folder"/>
<outline text="On change sidebar selection, load articles before updating unread count"/>
<outline text="Update Sparkle"/> <outline text="Update Sparkle"/>
<outline text="Use new app icon"/> <outline text="Use new app icon"/>
<outline text="Set -NSApplicationCrashOnExceptions YES"/> <outline text="Set -NSApplicationCrashOnExceptions YES"/>