mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2024-12-22 07:34:09 +01:00
Create handleUnreadCountDidChange as shared AppDelegate code.
This commit is contained in:
parent
79c2f4c7f5
commit
09cadf7f52
@ -56,6 +56,8 @@ import Sparkle
|
||||
|
||||
var isShutDownSyncDone = false
|
||||
|
||||
private static let logger = Logger(subsystem: Bundle.main.bundleIdentifier!, category: "AppDelegate")
|
||||
|
||||
@IBOutlet var debugMenuItem: NSMenuItem!
|
||||
@IBOutlet var sortByOldestArticleOnTopMenuItem: NSMenuItem!
|
||||
@IBOutlet var sortByNewestArticleOnTopMenuItem: NSMenuItem!
|
||||
@ -65,9 +67,7 @@ import Sparkle
|
||||
var unreadCount = 0 {
|
||||
didSet {
|
||||
if unreadCount != oldValue {
|
||||
queueUpdateDockBadge()
|
||||
AppNotification.postAppUnreadCountDidChange(from: self, unreadCount: unreadCount)
|
||||
postUnreadCountDidChangeNotification()
|
||||
handleUnreadCountDidChange()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,4 +26,20 @@ extension AppDelegate: FaviconDownloaderDelegate, FeedIconDownloaderDelegate {
|
||||
FaviconDownloader.shared.delegate = self
|
||||
FeedIconDownloader.shared.delegate = self
|
||||
}
|
||||
|
||||
func handleUnreadCountDidChange() {
|
||||
|
||||
AppNotification.postAppUnreadCountDidChange(from: self, unreadCount: unreadCount)
|
||||
postUnreadCountDidChangeNotification()
|
||||
updateBadge()
|
||||
}
|
||||
|
||||
func updateBadge() {
|
||||
|
||||
#if os(macOS)
|
||||
queueUpdateDockBadge()
|
||||
#elseif os(iOS)
|
||||
UNUserNotificationCenter.current().setBadgeCount(unreadCount)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -46,9 +46,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
|
||||
var unreadCount = 0 {
|
||||
didSet {
|
||||
if unreadCount != oldValue {
|
||||
AppNotification.postAppUnreadCountDidChange(from: self, unreadCount: unreadCount)
|
||||
postUnreadCountDidChangeNotification()
|
||||
UNUserNotificationCenter.current().setBadgeCount(unreadCount)
|
||||
handleUnreadCountDidChange()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user