From fc0fc2055ec44dd0c62763a34824127c2e7e0dde Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Tue, 13 Aug 2019 20:29:04 -0700 Subject: [PATCH] =?UTF-8?q?Get=20the=20unread=20count=20from=20the=20timel?= =?UTF-8?q?ine,=20instead=20of=20the=20database,=20only=20for=20the=20Toda?= =?UTF-8?q?y=20feed=20and=20only=20if=20it=E2=80=99s=20selected=20and=20it?= =?UTF-8?q?=E2=80=99s=20the=20only=20node=20selected.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sidebar/SidebarViewController.swift | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Mac/MainWindow/Sidebar/SidebarViewController.swift b/Mac/MainWindow/Sidebar/SidebarViewController.swift index 1b9f1d187..9c551167d 100644 --- a/Mac/MainWindow/Sidebar/SidebarViewController.swift +++ b/Mac/MainWindow/Sidebar/SidebarViewController.swift @@ -499,10 +499,11 @@ private extension SidebarViewController { func unreadCountFor(_ node: Node) -> Int { // If this node is the one and only selection, + // and it’s the Today feed, // then the unread count comes from the timeline. // This ensures that any transients in the timeline // are accounted for in the unread count. - if selectedNodes.count == 1 && node === selectedNodes.first! { + if nodeShouldGetUnreadCountFromTimeline(node) { return delegate?.unreadCount(for: node.representedObject) ?? 0 } @@ -512,6 +513,21 @@ private extension SidebarViewController { return 0 } + func nodeShouldGetUnreadCountFromTimeline(_ node: Node) -> Bool { + // Only if it’s selected, it’s the only node selected, + // and it’s the Today feed — which may have transients that are unread. + if selectedNodes.count != 1 { + return false + } + if node !== selectedNodes.first! { + return false + } + guard let smartFeed = node.representedObject as? SmartFeed else { + return false + } + return smartFeed.type == .today + } + func cellForRowView(_ rowView: NSTableRowView) -> SidebarCell? { return rowView.view(atColumn: 0) as? SidebarCell }