From 765b5e1a7cfe2bbd67d9795157cdd3287c30bbb3 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sat, 25 Feb 2023 15:02:55 -0500 Subject: [PATCH] Don't use KVO for updating timeline gap cell --- .../Screens/Timeline/TimelineViewController.swift | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/Tusker/Screens/Timeline/TimelineViewController.swift b/Tusker/Screens/Timeline/TimelineViewController.swift index 2bd629c7..c35280bd 100644 --- a/Tusker/Screens/Timeline/TimelineViewController.swift +++ b/Tusker/Screens/Timeline/TimelineViewController.swift @@ -44,7 +44,6 @@ class TimelineViewController: UIViewController, TimelineLikeCollectionViewContro private var cancellables = Set() private var userActivityNeedsUpdate = PassthroughSubject() - private var contentOffsetObservation: NSKeyValueObservation? // the last time this VC disappeared or the scene was backgrounded while it was active, used to decide if we want to check for present when reappearing private var disappearedAt: Date? @@ -140,13 +139,6 @@ class TimelineViewController: UIViewController, TimelineLikeCollectionViewContro collectionView.refreshControl!.addTarget(self, action: #selector(refresh), for: .valueChanged) #endif - contentOffsetObservation = collectionView.observe(\.contentOffset) { [weak self] _, _ in - if let indexPath = self?.dataSource.indexPath(for: .gap), - let cell = self?.collectionView.cellForItem(at: indexPath) as? TimelineGapCollectionViewCell { - cell.update() - } - } - filterer.filtersChanged = { [unowned self] actionsChanged in self.reapplyFilters(actionsChanged: actionsChanged) } @@ -1339,6 +1331,13 @@ extension TimelineViewController: UICollectionViewDelegate { func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) { userActivityNeedsUpdate.send() } + + func scrollViewDidScroll(_ scrollView: UIScrollView) { + if let indexPath = dataSource.indexPath(for: .gap), + let cell = collectionView.cellForItem(at: indexPath) as? TimelineGapCollectionViewCell { + cell.update() + } + } } extension TimelineViewController: UICollectionViewDragDelegate {