Use appDelegate’s coalescing queue for updating the dock badge.
This commit is contained in:
parent
1a5c9d130d
commit
d1137b7192
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue