Use appDelegate’s coalescing queue for updating the dock badge.

This commit is contained in:
Brent Simmons 2018-02-17 15:15:53 -08:00
parent 1a5c9d130d
commit d1137b7192
1 changed files with 3 additions and 7 deletions

View File

@ -15,16 +15,12 @@ import RSCore
func update() { func update() {
performSelectorCoalesced(#selector(updateBadge), with: nil, delay: 0.01) appDelegate?.coalescingQueue.add(self, #selector(updateBadge))
} }
@objc dynamic func updateBadge() { @objc func updateBadge() {
guard let appDelegate = appDelegate else { let unreadCount = appDelegate?.unreadCount ?? 0
return
}
let unreadCount = appDelegate.unreadCount
let label = unreadCount > 0 ? "\(unreadCount)" : "" let label = unreadCount > 0 ? "\(unreadCount)" : ""
NSApplication.shared.dockTile.badgeLabel = label NSApplication.shared.dockTile.badgeLabel = label
} }