Get the unread count from the timeline for the currently selected node in the sidebar. This ensures that transients in the timeline are accounted for. (The database query for the unread count wouldn’t necessarily match.)

This commit is contained in:
Brent Simmons
2019-07-27 22:53:27 -07:00
parent 05faea53c4
commit 44ec6a026d
4 changed files with 57 additions and 3 deletions

View File

@@ -387,6 +387,16 @@ extension MainWindowController: SidebarDelegate {
updateWindowTitle()
NotificationCenter.default.post(name: .InspectableObjectsDidChange, object: nil)
}
func unreadCount(for representedObject: AnyObject) -> Int {
guard let timelineViewController = regularTimelineViewController else {
return 0
}
guard timelineViewController.representsThisObjectOnly(representedObject) else {
return 0
}
return timelineViewController.unreadCount
}
}
// MARK: - TimelineContainerViewControllerDelegate
@@ -545,6 +555,10 @@ private extension MainWindowController {
return timelineContainerViewController?.currentTimelineViewController
}
var regularTimelineViewController: TimelineViewController? {
return timelineContainerViewController?.regularTimelineViewController
}
var sidebarSplitViewItem: NSSplitViewItem? {
return splitViewController?.splitViewItems[0]
}