From 7b964e05f9737461f389dd0374ea03fbf388c3dd Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Sat, 25 Nov 2017 15:21:35 -0800 Subject: [PATCH] =?UTF-8?q?Avoid=20looking=20for=20favicon=20when=20updati?= =?UTF-8?q?ng=20only=20a=20cell=E2=80=99s=20unread=20count.=20Micro-optimi?= =?UTF-8?q?zation.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sidebar/SidebarViewController.swift | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/Evergreen/MainWindow/Sidebar/SidebarViewController.swift b/Evergreen/MainWindow/Sidebar/SidebarViewController.swift index 6ff208bda..8db9ce9f7 100644 --- a/Evergreen/MainWindow/Sidebar/SidebarViewController.swift +++ b/Evergreen/MainWindow/Sidebar/SidebarViewController.swift @@ -63,7 +63,7 @@ import RSCore guard let representedObject = note.object else { return } - configureCellsForRepresentedObject(representedObject as AnyObject) + configureUnreadCountForCellsForRepresentedObject(representedObject as AnyObject) } @objc dynamic func containerChildrenDidChange(_ note: Notification) { @@ -343,6 +343,11 @@ private extension SidebarViewController { cell.shouldShowImage = node.representedObject is Feed } + func configureUnreadCount(_ cell: SidebarCell, _ node: Node) { + + cell.unreadCount = unreadCountFor(node) + } + func configureGroupCell(_ cell: NSTableCellView, _ node: Node) { cell.objectValue = node @@ -435,6 +440,16 @@ private extension SidebarViewController { return true } + func configureUnreadCountForCellsForRepresentedObject(_ representedObject: AnyObject) { + + cellsForRepresentedObject(representedObject).forEach { (cell) in + guard let node = cell.objectValue as? Node else { + return + } + configureUnreadCount(cell, node) + } + } + @discardableResult func revealAndSelectRepresentedObject(_ representedObject: AnyObject) -> Bool {