Get the unread count from the timeline, instead of the database, only for the Today feed and only if it’s selected and it’s the only node selected.

This commit is contained in:
Brent Simmons 2019-08-13 20:29:04 -07:00
parent cf1b3843ee
commit fc0fc2055e

View File

@ -499,10 +499,11 @@ private extension SidebarViewController {
func unreadCountFor(_ node: Node) -> Int {
// If this node is the one and only selection,
// and its 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 its selected, its the only node selected,
// and its 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
}