mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2026-11-29 16:54:12 +00:00
Coalesce Folder unread-count recalculation using CoalescingQueue. Run pending unread count updates before going to next unread. Fixes #5373.
This commit is contained in:
1 parent
96a7c3884b
commit
02cc7c2ffb
3 files changed
+15
-9
No files matched your search
@@ -387,6 +387,9 @@ final class MainWindowController: NSWindowController, NSUserInterfaceValidations
|
||||
return
|
||||
}
|
||||
|
||||
// Flush coalesced unread-count updates so folder counts are current.
|
||||
CoalescingQueue.standard.performCallsImmediately()
|
||||
|
||||
NSCursor.setHiddenUntilMouseMoves(true)
|
||||
|
||||
// TODO: handle search mode
|
||||
|
||||
@@ -92,7 +92,7 @@ public final class Folder: SidebarItem, Renamable, Container, Hashable {
|
||||
@objc func unreadCountDidChange(_ note: Notification) {
|
||||
if let object = note.object {
|
||||
if objectIsChild(object as AnyObject) {
|
||||
updateUnreadCount()
|
||||
CoalescingQueue.standard.add(self, #selector(updateUnreadCount))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -101,6 +101,14 @@ public final class Folder: SidebarItem, Renamable, Container, Hashable {
|
||||
updateUnreadCount()
|
||||
}
|
||||
|
||||
@objc func updateUnreadCount() {
|
||||
var updatedUnreadCount = 0
|
||||
for feed in topLevelFeeds {
|
||||
updatedUnreadCount += feed.unreadCount
|
||||
}
|
||||
unreadCount = updatedUnreadCount
|
||||
}
|
||||
|
||||
// MARK: Container
|
||||
|
||||
public func flattenedFeeds() -> Set<Feed> {
|
||||
@@ -165,14 +173,6 @@ public final class Folder: SidebarItem, Renamable, Container, Hashable {
|
||||
|
||||
private extension Folder {
|
||||
|
||||
func updateUnreadCount() {
|
||||
var updatedUnreadCount = 0
|
||||
for feed in topLevelFeeds {
|
||||
updatedUnreadCount += feed.unreadCount
|
||||
}
|
||||
unreadCount = updatedUnreadCount
|
||||
}
|
||||
|
||||
func childrenContain(_ feed: Feed) -> Bool {
|
||||
return topLevelFeeds.contains(feed)
|
||||
}
|
||||
|
||||
@@ -1157,6 +1157,9 @@ struct SidebarItemNode: Hashable, Sendable {
|
||||
|
||||
func selectNextUnread() {
|
||||
|
||||
// Flush coalesced unread-count updates so folder counts are current.
|
||||
CoalescingQueue.standard.performCallsImmediately()
|
||||
|
||||
// This should never happen, but I don't want to risk throwing us
|
||||
// into an infinite loop searching for an unread that isn't there.
|
||||
if AccountManager.shared.unreadCount < 1 {
|
||||
|
||||
Reference in new issue
Block a user