Merge branch 'mac-candidate'
This commit is contained in:
commit
7b3c08f521
@ -83,7 +83,12 @@ protocol SidebarDelegate: class {
|
||||
guard let representedObject = note.object else {
|
||||
return
|
||||
}
|
||||
configureUnreadCountForCellsForRepresentedObject(representedObject as AnyObject)
|
||||
if let timelineViewController = representedObject as? TimelineViewController {
|
||||
configureUnreadCountForCellsForRepresentedObjects(timelineViewController.representedObjects)
|
||||
}
|
||||
else {
|
||||
configureUnreadCountForCellsForRepresentedObjects([representedObject as AnyObject])
|
||||
}
|
||||
}
|
||||
|
||||
@objc func containerChildrenDidChange(_ note: Notification) {
|
||||
@ -502,7 +507,7 @@ private extension SidebarViewController {
|
||||
// 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 +517,18 @@ private extension SidebarViewController {
|
||||
return 0
|
||||
}
|
||||
|
||||
func nodeShouldGetUnreadCountFromTimeline(_ node: Node) -> Bool {
|
||||
// Only if it’s selected and it’s the only node selected.
|
||||
return selectedNodes.count == 1 && selectedNodes.first! === node
|
||||
}
|
||||
|
||||
func nodeRepresentsTodayFeed(_ node: Node) -> Bool {
|
||||
guard let smartFeed = node.representedObject as? SmartFeed else {
|
||||
return false
|
||||
}
|
||||
return smartFeed === SmartFeedsController.shared.todayFeed
|
||||
}
|
||||
|
||||
func cellForRowView(_ rowView: NSTableRowView) -> SidebarCell? {
|
||||
return rowView.view(atColumn: 0) as? SidebarCell
|
||||
}
|
||||
@ -537,8 +554,13 @@ private extension SidebarViewController {
|
||||
applyToCellsForRepresentedObject(representedObject, configure)
|
||||
}
|
||||
|
||||
func configureUnreadCountForCellsForRepresentedObject(_ representedObject: AnyObject) {
|
||||
applyToCellsForRepresentedObject(representedObject, configureUnreadCount)
|
||||
func configureUnreadCountForCellsForRepresentedObjects(_ representedObjects: [AnyObject]?) {
|
||||
guard let representedObjects = representedObjects else {
|
||||
return
|
||||
}
|
||||
for object in representedObjects {
|
||||
applyToCellsForRepresentedObject(object, configureUnreadCount)
|
||||
}
|
||||
}
|
||||
|
||||
@discardableResult
|
||||
|
Loading…
x
Reference in New Issue
Block a user