mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2025-01-03 13:30:14 +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
|
var isShutDownSyncDone = false
|
||||||
|
|
||||||
|
private static let logger = Logger(subsystem: Bundle.main.bundleIdentifier!, category: "AppDelegate")
|
||||||
|
|
||||||
@IBOutlet var debugMenuItem: NSMenuItem!
|
@IBOutlet var debugMenuItem: NSMenuItem!
|
||||||
@IBOutlet var sortByOldestArticleOnTopMenuItem: NSMenuItem!
|
@IBOutlet var sortByOldestArticleOnTopMenuItem: NSMenuItem!
|
||||||
@IBOutlet var sortByNewestArticleOnTopMenuItem: NSMenuItem!
|
@IBOutlet var sortByNewestArticleOnTopMenuItem: NSMenuItem!
|
||||||
@ -65,9 +67,7 @@ import Sparkle
|
|||||||
var unreadCount = 0 {
|
var unreadCount = 0 {
|
||||||
didSet {
|
didSet {
|
||||||
if unreadCount != oldValue {
|
if unreadCount != oldValue {
|
||||||
queueUpdateDockBadge()
|
handleUnreadCountDidChange()
|
||||||
AppNotification.postAppUnreadCountDidChange(from: self, unreadCount: unreadCount)
|
|
||||||
postUnreadCountDidChangeNotification()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,4 +26,20 @@ extension AppDelegate: FaviconDownloaderDelegate, FeedIconDownloaderDelegate {
|
|||||||
FaviconDownloader.shared.delegate = self
|
FaviconDownloader.shared.delegate = self
|
||||||
FeedIconDownloader.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 {
|
var unreadCount = 0 {
|
||||||
didSet {
|
didSet {
|
||||||
if unreadCount != oldValue {
|
if unreadCount != oldValue {
|
||||||
AppNotification.postAppUnreadCountDidChange(from: self, unreadCount: unreadCount)
|
handleUnreadCountDidChange()
|
||||||
postUnreadCountDidChangeNotification()
|
|
||||||
UNUserNotificationCenter.current().setBadgeCount(unreadCount)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user