From 5f4a0540eff16d5831cf756e9c602cab51f7b12a Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Fri, 10 Mar 2023 14:47:37 -0600 Subject: [PATCH] Change how we mark as read on scroll on iOS so that it works more how a user would expect it to regarding the safe area --- .../MasterTimelineViewController.swift | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/iOS/MasterTimeline/MasterTimelineViewController.swift b/iOS/MasterTimeline/MasterTimelineViewController.swift index c1d1c3ef2..bd35944da 100644 --- a/iOS/MasterTimeline/MasterTimelineViewController.swift +++ b/iOS/MasterTimeline/MasterTimelineViewController.swift @@ -35,7 +35,6 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner weak var coordinator: SceneCoordinator! var undoableCommands = [UndoableCommand]() - let scrollPositionQueue = CoalescingQueue(name: "Timeline Scroll Position", interval: 0.3, maxInterval: 1.0) private let keyboardManager = KeyboardManager(type: .timeline) override var keyCommands: [UIKeyCommand]? { @@ -433,21 +432,26 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner coordinator.selectArticle(article, animations: [.scroll, .select, .navigation]) } - override func tableView(_ tableView: UITableView, didEndDisplaying cell: UITableViewCell, forRowAt indexPath: IndexPath) { + override func scrollViewDidScroll(_ scrollView: UIScrollView) { + coordinator.timelineMiddleIndexPath = tableView.middleVisibleRow() + + // Implement Mark As Read on Scroll where we mark after the leading edge goes a little beyond the safe area inset guard AppDefaults.shared.markArticlesAsReadOnScroll, - let firstVisible = tableView.indexPathsForVisibleRows?.first, - indexPath < firstVisible, - let article = dataSource.itemIdentifier(for: indexPath), - article.status.read == false, - !coordinator.directlyMarkedAsUnreadArticles.contains(article) else { - return + let firstVisibleindexPath = tableView.indexPathsForVisibleRows?.first else { return } + + var articles = [Article]() + for i in firstVisibleindexPath.row..