Notifications Manager Perf Improvements

Adopts prefetch for smooth scrolling
This commit is contained in:
Stuart Breckenridge
2022-02-04 10:10:32 +08:00
parent f611d9ccac
commit 8a4156542b
4 changed files with 25 additions and 32 deletions

View File

@@ -10,11 +10,8 @@ import UIKit
import Account
import UserNotifications
extension Notification.Name {
static let NotificationPreferencesDidUpdate = Notification.Name("NotificationPreferencesDidUpdate")
}
class NotificationsTableViewCell: UITableViewCell {
class NotificationsTableViewCell: VibrantBasicTableViewCell {
@IBOutlet weak var notificationsSwitch: UISwitch!
@IBOutlet weak var notificationsLabel: UILabel!
@@ -33,7 +30,7 @@ class NotificationsTableViewCell: UITableViewCell {
// Configure the view for the selected state
}
func configure(_ webFeed: WebFeed, _ status: UNAuthorizationStatus) {
func configure(_ webFeed: WebFeed) {
self.feed = webFeed
var isOn = false
if webFeed.isNotifyAboutNewArticles == nil {
@@ -43,9 +40,8 @@ class NotificationsTableViewCell: UITableViewCell {
}
notificationsSwitch.isOn = isOn
notificationsSwitch.addTarget(self, action: #selector(toggleWebFeedNotification(_:)), for: .touchUpInside)
if status == .denied { notificationsSwitch.isEnabled = false }
notificationsLabel.text = webFeed.nameForDisplay
notificationsImageView.image = webFeed.smallIcon?.image
notificationsImageView.image = IconImageCache.shared.imageFor(webFeed.feedID!)?.image
notificationsImageView.layer.cornerRadius = 4
}
@@ -61,14 +57,5 @@ class NotificationsTableViewCell: UITableViewCell {
feed.isNotifyAboutNewArticles!.toggle()
}
}
@objc
private func requestNotificationPermissions(_ sender: Any) {
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .badge, .sound]) { success, error in
NotificationCenter.default.post(name: .NotificationPreferencesDidUpdate, object: nil)
}
}
}