diff --git a/Account/Sources/Account/Feed.swift b/Account/Sources/Account/Feed.swift index 5f9db154b..846eb15ac 100644 --- a/Account/Sources/Account/Feed.swift +++ b/Account/Sources/Account/Feed.swift @@ -121,12 +121,12 @@ import Core } } - public var isNotifyAboutNewArticles: Bool? { + public var shouldSendUserNotificationForNewArticles: Bool? { get { - return metadata.isNotifyAboutNewArticles + return metadata.shouldSendUserNotificationForNewArticles } set { - metadata.isNotifyAboutNewArticles = newValue + metadata.shouldSendUserNotificationForNewArticles = newValue } } diff --git a/Account/Sources/Account/FeedMetadata.swift b/Account/Sources/Account/FeedMetadata.swift index cb5efca3d..8f7ee6c77 100644 --- a/Account/Sources/Account/FeedMetadata.swift +++ b/Account/Sources/Account/FeedMetadata.swift @@ -24,7 +24,7 @@ final class FeedMetadata: Codable { case editedName case authors case contentHash - case isNotifyAboutNewArticles + case shouldSendUserNotificationForNewArticles = "isNotifyAboutNewArticles" case isArticleExtractorAlwaysOn case conditionalGetInfo case sinceToken @@ -74,10 +74,10 @@ final class FeedMetadata: Codable { } } - var isNotifyAboutNewArticles: Bool? { + var shouldSendUserNotificationForNewArticles: Bool? { didSet { - if isNotifyAboutNewArticles != oldValue { - valueDidChange(.isNotifyAboutNewArticles) + if shouldSendUserNotificationForNewArticles != oldValue { + valueDidChange(.shouldSendUserNotificationForNewArticles) } } } diff --git a/Mac/Inspector/FeedInspectorViewController.swift b/Mac/Inspector/FeedInspectorViewController.swift index f1d29818a..0cb32b8e3 100644 --- a/Mac/Inspector/FeedInspectorViewController.swift +++ b/Mac/Inspector/FeedInspectorViewController.swift @@ -80,14 +80,14 @@ import UserNotifications } } else if settings.authorizationStatus == .authorized { DispatchQueue.main.async { - self.feed?.isNotifyAboutNewArticles = (self.isNotifyAboutNewArticlesCheckBox?.state ?? .off) == .on ? true : false + self.feed?.shouldSendUserNotificationForNewArticles = (self.isNotifyAboutNewArticlesCheckBox?.state ?? .off) == .on ? true : false } } else { UNUserNotificationCenter.current().requestAuthorization(options: [.badge, .sound, .alert]) { (granted, error) in self.updateNotificationSettings() if granted { DispatchQueue.main.async { - self.feed?.isNotifyAboutNewArticles = (self.isNotifyAboutNewArticlesCheckBox?.state ?? .off) == .on ? true : false + self.feed?.shouldSendUserNotificationForNewArticles = (self.isNotifyAboutNewArticlesCheckBox?.state ?? .off) == .on ? true : false NSApplication.shared.registerForRemoteNotifications() } } else { @@ -171,7 +171,7 @@ private extension FeedInspectorViewController { func updateNotifyAboutNewArticles() { isNotifyAboutNewArticlesCheckBox?.title = feed?.notificationDisplayName ?? NSLocalizedString("Show notifications for new articles", comment: "Show notifications for new articles") - isNotifyAboutNewArticlesCheckBox?.state = (feed?.isNotifyAboutNewArticles ?? false) ? .on : .off + isNotifyAboutNewArticlesCheckBox?.state = (feed?.shouldSendUserNotificationForNewArticles ?? false) ? .on : .off } func updateIsReaderViewAlwaysOn() { diff --git a/Mac/MainWindow/Sidebar/SidebarViewController+ContextualMenus.swift b/Mac/MainWindow/Sidebar/SidebarViewController+ContextualMenus.swift index bb5484ba7..c4e05dbcc 100644 --- a/Mac/MainWindow/Sidebar/SidebarViewController+ContextualMenus.swift +++ b/Mac/MainWindow/Sidebar/SidebarViewController+ContextualMenus.swift @@ -117,16 +117,16 @@ extension SidebarViewController { self.showNotificationsNotEnabledAlert() } else if settings.authorizationStatus == .authorized { DispatchQueue.main.async { - if feed.isNotifyAboutNewArticles == nil { feed.isNotifyAboutNewArticles = false } - feed.isNotifyAboutNewArticles?.toggle() + if feed.shouldSendUserNotificationForNewArticles == nil { feed.shouldSendUserNotificationForNewArticles = false } + feed.shouldSendUserNotificationForNewArticles?.toggle() NotificationCenter.default.post(Notification(name: .DidUpdateFeedPreferencesFromContextMenu)) } } else { UNUserNotificationCenter.current().requestAuthorization(options: [.badge, .sound, .alert]) { (granted, error) in if granted { DispatchQueue.main.async { - if feed.isNotifyAboutNewArticles == nil { feed.isNotifyAboutNewArticles = false } - feed.isNotifyAboutNewArticles?.toggle() + if feed.shouldSendUserNotificationForNewArticles == nil { feed.shouldSendUserNotificationForNewArticles = false } + feed.shouldSendUserNotificationForNewArticles?.toggle() NotificationCenter.default.post(Notification(name: .DidUpdateFeedPreferencesFromContextMenu)) NSApplication.shared.registerForRemoteNotifications() } @@ -226,7 +226,7 @@ private extension SidebarViewController { let notificationText = feed.notificationDisplayName.capitalized let notificationMenuItem = menuItem(notificationText, #selector(toggleNotificationsFromContextMenu(_:)), feed) - if feed.isNotifyAboutNewArticles == nil || feed.isNotifyAboutNewArticles! == false { + if feed.shouldSendUserNotificationForNewArticles == nil || feed.shouldSendUserNotificationForNewArticles! == false { notificationMenuItem.state = .off } else { notificationMenuItem.state = .on diff --git a/Shared/UserNotifications/UserNotificationManager.swift b/Shared/UserNotifications/UserNotificationManager.swift index eafcb41f9..e61385279 100644 --- a/Shared/UserNotifications/UserNotificationManager.swift +++ b/Shared/UserNotifications/UserNotificationManager.swift @@ -26,7 +26,7 @@ final class UserNotificationManager: Sendable { Task { @MainActor in for article in articles { - if !article.status.read, let feed = article.feed, feed.isNotifyAboutNewArticles ?? false { + if !article.status.read, let feed = article.feed, feed.shouldSendUserNotificationForNewArticles ?? false { sendNotification(feed: feed, article: article) } } diff --git a/iOS/Inspector/FeedInspectorViewController.swift b/iOS/Inspector/FeedInspectorViewController.swift index c1327eacd..b7b666e18 100644 --- a/iOS/Inspector/FeedInspectorViewController.swift +++ b/iOS/Inspector/FeedInspectorViewController.swift @@ -42,7 +42,7 @@ class FeedInspectorViewController: UITableViewController { navigationItem.title = feed.nameForDisplay nameTextField.text = feed.nameForDisplay - notifyAboutNewArticlesSwitch.setOn(feed.isNotifyAboutNewArticles ?? false, animated: false) + notifyAboutNewArticlesSwitch.setOn(feed.shouldSendUserNotificationForNewArticles ?? false, animated: false) alwaysShowReaderViewSwitch.setOn(feed.isArticleExtractorAlwaysOn ?? false, animated: false) @@ -84,13 +84,13 @@ class FeedInspectorViewController: UITableViewController { notifyAboutNewArticlesSwitch.isOn = !notifyAboutNewArticlesSwitch.isOn present(notificationUpdateErrorAlert(), animated: true, completion: nil) } else if settings.authorizationStatus == .authorized { - feed.isNotifyAboutNewArticles = notifyAboutNewArticlesSwitch.isOn + feed.shouldSendUserNotificationForNewArticles = notifyAboutNewArticlesSwitch.isOn } else { UNUserNotificationCenter.current().requestAuthorization(options:[.badge, .sound, .alert]) { (granted, error) in self.updateNotificationSettings() if granted { DispatchQueue.main.async { - self.feed.isNotifyAboutNewArticles = self.notifyAboutNewArticlesSwitch.isOn + self.feed.shouldSendUserNotificationForNewArticles = self.notifyAboutNewArticlesSwitch.isOn UIApplication.shared.registerForRemoteNotifications() } } else {