You can’t toggle an optional Bool

This commit is contained in:
Stuart Breckenridge 2021-02-02 13:25:06 +08:00
parent aa0a5d2269
commit e88327be78
No known key found for this signature in database
GPG Key ID: 1F11FD62007DC331
1 changed files with 3 additions and 0 deletions

View File

@ -114,6 +114,7 @@ extension SidebarViewController {
self.showNotificationsNotEnabledAlert() self.showNotificationsNotEnabledAlert()
} else if settings.authorizationStatus == .authorized { } else if settings.authorizationStatus == .authorized {
DispatchQueue.main.async { DispatchQueue.main.async {
if feed.isNotifyAboutNewArticles == nil { feed.isNotifyAboutNewArticles = false }
feed.isNotifyAboutNewArticles?.toggle() feed.isNotifyAboutNewArticles?.toggle()
NotificationCenter.default.post(Notification(name: .DidUpdateFeedPreferencesFromContextMenu)) NotificationCenter.default.post(Notification(name: .DidUpdateFeedPreferencesFromContextMenu))
} }
@ -121,6 +122,7 @@ extension SidebarViewController {
UNUserNotificationCenter.current().requestAuthorization(options: [.badge, .sound, .alert]) { (granted, error) in UNUserNotificationCenter.current().requestAuthorization(options: [.badge, .sound, .alert]) { (granted, error) in
if granted { if granted {
DispatchQueue.main.async { DispatchQueue.main.async {
if feed.isNotifyAboutNewArticles == nil { feed.isNotifyAboutNewArticles = false }
feed.isNotifyAboutNewArticles?.toggle() feed.isNotifyAboutNewArticles?.toggle()
NotificationCenter.default.post(Notification(name: .DidUpdateFeedPreferencesFromContextMenu)) NotificationCenter.default.post(Notification(name: .DidUpdateFeedPreferencesFromContextMenu))
NSApplication.shared.registerForRemoteNotifications() NSApplication.shared.registerForRemoteNotifications()
@ -138,6 +140,7 @@ extension SidebarViewController {
let feed = item.representedObject as? WebFeed else { let feed = item.representedObject as? WebFeed else {
return return
} }
if feed.isArticleExtractorAlwaysOn == nil { feed.isArticleExtractorAlwaysOn = false }
feed.isArticleExtractorAlwaysOn?.toggle() feed.isArticleExtractorAlwaysOn?.toggle()
NotificationCenter.default.post(Notification(name: .DidUpdateFeedPreferencesFromContextMenu)) NotificationCenter.default.post(Notification(name: .DidUpdateFeedPreferencesFromContextMenu))
} }