Fix bug where sidebar unread count view would flicker as the timeline view controller unreadCount would be briefly 0 when it’s updating its unread count.

This commit is contained in:
Brent Simmons 2024-06-21 18:09:28 -07:00
parent 16b2e55f5f
commit 9a26df89d1

View File

@ -815,14 +815,18 @@ private extension SidebarViewController {
// then the unread count comes from the timeline. // then the unread count comes from the timeline.
// This ensures that any transients in the timeline // This ensures that any transients in the timeline
// are accounted for in the unread count. // are accounted for in the unread count.
if nodeShouldGetUnreadCountFromTimeline(node) {
return delegate?.unreadCount(for: node.representedObject) ?? 0 var count = 0
if let unreadCountProvider = node.representedObject as? UnreadCountProvider {
count = unreadCountProvider.unreadCount
} }
if let unreadCountProvider = node.representedObject as? UnreadCountProvider { if nodeShouldGetUnreadCountFromTimeline(node) {
return unreadCountProvider.unreadCount let timelineUnreadCount = delegate?.unreadCount(for: node.representedObject) ?? 0
return max(count, timelineUnreadCount) // timelineUnreadCount may include additional transients
} }
return 0
return count
} }
func nodeShouldGetUnreadCountFromTimeline(_ node: Node) -> Bool { func nodeShouldGetUnreadCountFromTimeline(_ node: Node) -> Bool {