From d71884a106e38709c1c824f5ca244bbfae77e313 Mon Sep 17 00:00:00 2001 From: Stuart Breckenridge Date: Fri, 11 Feb 2022 07:45:32 +0800 Subject: [PATCH 1/2] gets rid of unneccessary tracking --- iOS/Settings/NotificationsViewController.swift | 8 -------- 1 file changed, 8 deletions(-) diff --git a/iOS/Settings/NotificationsViewController.swift b/iOS/Settings/NotificationsViewController.swift index 82f8d07db..8016a87cb 100644 --- a/iOS/Settings/NotificationsViewController.swift +++ b/iOS/Settings/NotificationsViewController.swift @@ -33,7 +33,6 @@ class NotificationsViewController: UIViewController { } } private var filterButton: UIBarButtonItem! - private var prefetchedIndexPaths = Set() override func viewDidLoad() { super.viewDidLoad() @@ -74,20 +73,16 @@ class NotificationsViewController: UIViewController { @objc private func updateCellsFrom(_ notification: Notification) { guard let webFeed = notification.userInfo?[UserInfoKey.webFeed] as? WebFeed else { return } - if let visibleIndexPaths = notificationsTableView.indexPathsForVisibleRows { for path in visibleIndexPaths { if let cell = notificationsTableView.cellForRow(at: path) as? NotificationsTableViewCell { if cell.feed! == webFeed { notificationsTableView.reconfigureRows(at: [path]) - return } } } } - - } @objc @@ -228,19 +223,16 @@ extension NotificationsViewController: UITableViewDataSource { let cell = tableView.dequeueReusableCell(withIdentifier: "NotificationsCell") as! NotificationsTableViewCell let account = AccountManager.shared.sortedActiveAccounts[indexPath.section - 1] cell.configure(filteredWebFeeds(searchController.searchBar.text, account: account)[indexPath.row]) - prefetchedIndexPaths.insert(indexPath) return cell } else if newArticleNotificationFilter == true { let cell = tableView.dequeueReusableCell(withIdentifier: "NotificationsCell") as! NotificationsTableViewCell let account = AccountManager.shared.sortedActiveAccounts[indexPath.section - 1] cell.configure(feedsWithNotificationsEnabled(account)[indexPath.row]) - prefetchedIndexPaths.insert(indexPath) return cell } else { let cell = tableView.dequeueReusableCell(withIdentifier: "NotificationsCell") as! NotificationsTableViewCell let account = AccountManager.shared.sortedActiveAccounts[indexPath.section - 1] cell.configure(sortedWebFeedsForAccount(account)[indexPath.row]) - prefetchedIndexPaths.insert(indexPath) return cell } } From 0ff1e19849f7df9a8899557c1780c1632b83d20f Mon Sep 17 00:00:00 2001 From: Stuart Breckenridge Date: Fri, 11 Feb 2022 11:35:25 +0800 Subject: [PATCH 2/2] Improves performance of notifications view --- iOS/Settings/NotificationsViewController.swift | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/iOS/Settings/NotificationsViewController.swift b/iOS/Settings/NotificationsViewController.swift index 8016a87cb..1c4d78524 100644 --- a/iOS/Settings/NotificationsViewController.swift +++ b/iOS/Settings/NotificationsViewController.swift @@ -77,7 +77,7 @@ class NotificationsViewController: UIViewController { for path in visibleIndexPaths { if let cell = notificationsTableView.cellForRow(at: path) as? NotificationsTableViewCell { if cell.feed! == webFeed { - notificationsTableView.reconfigureRows(at: [path]) + cell.configure(webFeed) return } } @@ -87,8 +87,20 @@ class NotificationsViewController: UIViewController { @objc private func reloadVisibleCells(_ notification: Notification) { - if let visibleIndexPaths = notificationsTableView.indexPathsForVisibleRows { - notificationsTableView.reconfigureRows(at: visibleIndexPaths) + guard let faviconURLString = notification.userInfo?["faviconURL"] as? String, + let faviconHost = URL(string: faviconURLString)?.host else { + return + } + + for cell in notificationsTableView.visibleCells { + if let notificationCell = cell as? NotificationsTableViewCell { + if let feedURLHost = URL(string: notificationCell.feed!.url)?.host { + if faviconHost == feedURLHost { + notificationCell.configure(notificationCell.feed!) + return + } + } + } } }