Rename isNotifyAboutNewArticles to shouldSendUserNotificationForNewArticles

This commit is contained in:
Brent Simmons 2024-05-25 23:05:38 -07:00
parent 33215ba9e3
commit 401050465e
6 changed files with 19 additions and 19 deletions

View File

@ -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
}
}

View File

@ -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)
}
}
}

View File

@ -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() {

View File

@ -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

View File

@ -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)
}
}

View File

@ -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 {