2017-10-06 03:01:18 +02:00
|
|
|
//
|
|
|
|
// DockBadge.swift
|
|
|
|
// Evergreen
|
|
|
|
//
|
|
|
|
// Created by Brent Simmons on 10/5/17.
|
|
|
|
// Copyright © 2017 Ranchero Software. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
import RSCore
|
|
|
|
|
|
|
|
@objc final class DockBadge: NSObject {
|
|
|
|
|
|
|
|
weak var appDelegate: AppDelegate?
|
|
|
|
|
|
|
|
func update() {
|
|
|
|
|
2018-02-18 02:45:05 +01:00
|
|
|
CoalescingQueue.standard.add(self, #selector(updateBadge))
|
2017-10-06 03:01:18 +02:00
|
|
|
}
|
|
|
|
|
2018-02-18 00:15:53 +01:00
|
|
|
@objc func updateBadge() {
|
2017-10-06 03:01:18 +02:00
|
|
|
|
2018-02-18 00:15:53 +01:00
|
|
|
let unreadCount = appDelegate?.unreadCount ?? 0
|
2017-10-06 03:01:18 +02:00
|
|
|
let label = unreadCount > 0 ? "\(unreadCount)" : ""
|
|
|
|
NSApplication.shared.dockTile.badgeLabel = label
|
|
|
|
}
|
|
|
|
}
|