Merge pull request #3021 from stuartbreckenridge/fix/3014

Naming convention for notification options
This commit is contained in:
Brent Simmons 2021-04-21 18:02:11 -07:00 committed by GitHub
commit 77cd189c75
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 32 additions and 2 deletions

View File

@ -240,6 +240,27 @@ public final class WebFeed: Feed, Renamable, Hashable {
return true
}
}
// MARK: - NotificationDisplayName
public var notificationDisplayName: String {
#if os(macOS)
if self.url.contains("twitter.com") {
return NSLocalizedString("Show notifications for new tweets", comment: "notifyNameDisplay / Twitter")
} else if self.url.contains("www.reddit.com") {
return NSLocalizedString("Show notifications for new posts", comment: "notifyNameDisplay / Reddit")
} else {
return NSLocalizedString("Show notifications for new articles", comment: "notifyNameDisplay / Default")
}
#else
if self.url.contains("twitter.com") {
return NSLocalizedString("Notify about new tweets", comment: "notifyNameDisplay / Twitter")
} else if self.url.contains("www.reddit.com") {
return NSLocalizedString("Notify about new posts", comment: "notifyNameDisplay / Reddit")
} else {
return NSLocalizedString("Notify about new articles", comment: "notifyNameDisplay / Default")
}
#endif
}
var metadata: WebFeedMetadata

View File

@ -183,6 +183,7 @@ private extension WebFeedInspectorViewController {
}
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
}

View File

@ -230,7 +230,7 @@ private extension SidebarViewController {
}
menu.addItem(NSMenuItem.separator())
let notificationText = NSLocalizedString("Show Notifications for New Articles", comment: "Show Notifications for New Articles")
let notificationText = webFeed.notificationDisplayName.capitalized
let notificationMenuItem = menuItem(notificationText, #selector(toggleNotificationsFromContextMenu(_:)), webFeed)
if webFeed.isNotifyAboutNewArticles == nil || webFeed.isNotifyAboutNewArticles! == false {

View File

@ -156,7 +156,15 @@ extension WebFeedInspectorViewController {
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
super.tableView(tableView, cellForRowAt: shift(indexPath))
let cell = super.tableView(tableView, cellForRowAt: shift(indexPath))
if indexPath.section == 0 && indexPath.row == 1 {
guard let label = cell.contentView.subviews.filter({ $0.isKind(of: UILabel.self) })[0] as? UILabel else {
return cell
}
label.numberOfLines = 2
label.text = webFeed.notificationDisplayName.capitalized
}
return cell
}
override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {