diff --git a/Evergreen/MainWindow/Sidebar/SidebarViewController.swift b/Evergreen/MainWindow/Sidebar/SidebarViewController.swift index 2ec301d64..1438e3b5c 100644 --- a/Evergreen/MainWindow/Sidebar/SidebarViewController.swift +++ b/Evergreen/MainWindow/Sidebar/SidebarViewController.swift @@ -37,6 +37,7 @@ import RSCore NotificationCenter.default.addObserver(self, selector: #selector(containerChildrenDidChange(_:)), name: .ChildrenDidChange, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(userDidAddFeed(_:)), name: .UserDidAddFeed, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(batchUpdateDidPerform(_:)), name: .BatchUpdateDidPerform, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(faviconDidBecomeAvailable(_:)), name: .FaviconDidBecomeAvailable, object: nil) outlineView.reloadData() @@ -82,6 +83,11 @@ import RSCore revealAndSelectRepresentedObject(feed) } + @objc func faviconDidBecomeAvailable(_ note: Notification) { + + configureAvailableCells() + } + // MARK: Actions @IBAction func delete(_ sender: AnyObject?) { @@ -358,20 +364,35 @@ private extension SidebarViewController { return 0 } + func cellForRowView(_ rowView: NSTableRowView) -> SidebarCell? { + + return rowView.view(atColumn: 0) as? SidebarCell + } + func availableSidebarCells() -> [SidebarCell] { var cells = [SidebarCell]() outlineView.enumerateAvailableRowViews { (rowView: NSTableRowView, _: Int) -> Void in - - if let oneSidebarCell = rowView.view(atColumn: 0) as? SidebarCell { - cells += [oneSidebarCell] + if let cell = cellForRowView(rowView) { + cells += [cell] } } return cells } + func configureAvailableCells() { + + outlineView.enumerateAvailableRowViews { (rowView: NSTableRowView, row: Int) -> Void in + + guard let cell = cellForRowView(rowView), let node = nodeForRow(row) else { + return + } + configure(cell, node) + } + } + func cellsForRepresentedObject(_ representedObject: AnyObject) -> [SidebarCell] { let availableCells = availableSidebarCells()