mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
notifications
This commit is contained in:
@@ -16,7 +16,7 @@ class NotificationsTableViewCell: VibrantBasicTableViewCell {
|
||||
@IBOutlet weak var notificationsSwitch: UISwitch!
|
||||
@IBOutlet weak var notificationsLabel: UILabel!
|
||||
@IBOutlet weak var notificationsImageView: UIImageView!
|
||||
var feed: WebFeed?
|
||||
weak var feed: WebFeed?
|
||||
|
||||
|
||||
override func awakeFromNib() {
|
||||
@@ -31,6 +31,7 @@ class NotificationsTableViewCell: VibrantBasicTableViewCell {
|
||||
}
|
||||
|
||||
func configure(_ webFeed: WebFeed) {
|
||||
print("NotificationTableView: configuring cell: \(webFeed.nameForDisplay)")
|
||||
self.feed = webFeed
|
||||
var isOn = false
|
||||
if webFeed.isNotifyAboutNewArticles == nil {
|
||||
@@ -43,6 +44,7 @@ class NotificationsTableViewCell: VibrantBasicTableViewCell {
|
||||
notificationsLabel.text = webFeed.nameForDisplay
|
||||
notificationsImageView.image = IconImageCache.shared.imageFor(webFeed.feedID!)?.image
|
||||
notificationsImageView.layer.cornerRadius = 4
|
||||
print("NotificationTableView: configured cell: \(webFeed.nameForDisplay)")
|
||||
}
|
||||
|
||||
@objc
|
||||
|
||||
@@ -38,7 +38,6 @@ class NotificationsViewController: UIViewController {
|
||||
super.viewDidLoad()
|
||||
title = NSLocalizedString("New Article Notifications", comment: "Notifications")
|
||||
|
||||
notificationsTableView.prefetchDataSource = self
|
||||
navigationItem.searchController = searchController
|
||||
|
||||
filterButton = UIBarButtonItem(
|
||||
@@ -51,6 +50,7 @@ class NotificationsViewController: UIViewController {
|
||||
|
||||
reloadNotificationTableView()
|
||||
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(updateCellsFrom(_:)), name: .WebFeedIconDidBecomeAvailable, object: nil)
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(reloadNotificationTableView(_:)), name: UIScene.willEnterForegroundNotification, object: nil)
|
||||
}
|
||||
|
||||
@@ -68,6 +68,23 @@ class NotificationsViewController: UIViewController {
|
||||
}
|
||||
}
|
||||
|
||||
@objc
|
||||
private func updateCellsFrom(_ notification: Notification) {
|
||||
guard let webFeed = notification.userInfo?[UserInfoKey.webFeed] as? WebFeed else { return }
|
||||
print("NotificationTableView: Received WebFeedIcon for \(webFeed.nameForDisplay)")
|
||||
|
||||
let cell = notificationsTableView.visibleCells.filter({ ($0 as? NotificationsTableViewCell)?.feed == webFeed }).first as? NotificationsTableViewCell
|
||||
if cell != nil {
|
||||
if let indexPath = notificationsTableView.indexPath(for: cell!) {
|
||||
notificationsTableView.reconfigureRows(at: [indexPath])
|
||||
print("NotificationTableView: Reconfigured cell for \(webFeed.nameForDisplay)")
|
||||
return
|
||||
}
|
||||
} else {
|
||||
print("NotificationTableView: Cannot find cell for \(webFeed.nameForDisplay)")
|
||||
}
|
||||
}
|
||||
|
||||
private func notificationFilterMenu() -> UIMenu {
|
||||
|
||||
if filterButton != nil {
|
||||
@@ -242,19 +259,6 @@ extension NotificationsViewController: UITableViewDelegate {
|
||||
}
|
||||
|
||||
|
||||
extension NotificationsViewController: UITableViewDataSourcePrefetching {
|
||||
|
||||
func tableView(_ tableView: UITableView, prefetchRowsAt indexPaths: [IndexPath]) {
|
||||
for path in indexPaths {
|
||||
let account = AccountManager.shared.sortedActiveAccounts[path.section - 1]
|
||||
let feed = sortedWebFeedsForAccount(account)[path.row]
|
||||
let _ = IconImageCache.shared.imageFor(feed.feedID!)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// MARK: - UISearchControllerDelegate
|
||||
extension NotificationsViewController: UISearchControllerDelegate {
|
||||
|
||||
|
||||
@@ -1194,7 +1194,7 @@
|
||||
<constraint firstItem="dsQ-vy-iVG" firstAttribute="top" secondItem="2EC-mY-aSE" secondAttribute="top" id="3o7-Oa-Qhq"/>
|
||||
<constraint firstItem="dsQ-vy-iVG" firstAttribute="leading" secondItem="32c-qn-nBM" secondAttribute="leading" id="V01-Fb-OvO"/>
|
||||
<constraint firstItem="32c-qn-nBM" firstAttribute="trailing" secondItem="dsQ-vy-iVG" secondAttribute="trailing" id="WTV-jU-eAU"/>
|
||||
<constraint firstItem="dsQ-vy-iVG" firstAttribute="bottom" secondItem="32c-qn-nBM" secondAttribute="bottom" constant="34" id="nQh-bT-XE2"/>
|
||||
<constraint firstItem="dsQ-vy-iVG" firstAttribute="bottom" secondItem="2EC-mY-aSE" secondAttribute="bottom" id="nQh-bT-XE2"/>
|
||||
</constraints>
|
||||
</view>
|
||||
<navigationItem key="navigationItem" id="sdU-Jy-5dq"/>
|
||||
|
||||
Reference in New Issue
Block a user