From 78ee06695bb46f060ffc2e68aab86e57f098ac67 Mon Sep 17 00:00:00 2001 From: Yusuf Suleman Date: Sat, 4 Apr 2026 00:08:57 -0500 Subject: [PATCH] =?UTF-8?q?fix:=20scroll=20direction=20check=20always=20fa?= =?UTF-8?q?iled=20=E2=80=94=20read=20prevMinY=20before=20write?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: lastKnownMinY[entryId] was set to newMinY on line 83, then read back on line 97 to check direction. Since it was just set to newMinY, the check (lastKnownMinY[entryId] <= newMinY) was always true, making isMovingUp always true, so the guard always failed. Fix: Read prevMinY BEFORE writing newMinY. Compute isScrollingDown from the delta between prev and new. Use that boolean in the guard. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../Features/Reader/Views/EntryListView.swift | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/ios/Platform/Platform/Features/Reader/Views/EntryListView.swift b/ios/Platform/Platform/Features/Reader/Views/EntryListView.swift index 5525e24..d42b389 100644 --- a/ios/Platform/Platform/Features/Reader/Views/EntryListView.swift +++ b/ios/Platform/Platform/Features/Reader/Views/EntryListView.swift @@ -69,17 +69,21 @@ struct EntryListView: View { guard entryHeight > 0 else { return } // --- Scroll direction + activation --- - if let prev = lastKnownMinY[entryId] { + let prevMinY = lastKnownMinY[entryId] + let isScrollingDown: Bool + if let prev = prevMinY { let delta = prev - newMinY // positive = scrolling down - if delta > 2 { + isScrollingDown = delta > 2 + if isScrollingDown { cumulativeDown += delta if cumulativeDown > activationThreshold { trackingActive = true } } - // Don't reset trackingActive on upward scroll — - // just don't mark anything. Keeps cumulative progress. + } else { + isScrollingDown = false } + // Store AFTER reading previous value lastKnownMinY[entryId] = newMinY // --- Visibility tracking --- @@ -92,11 +96,8 @@ struct EntryListView: View { } // --- Mark-as-read --- - // Current scroll direction for THIS entry is "down" - // if its minY decreased since last check - let isMovingUp = (lastKnownMinY[entryId] ?? 0) <= newMinY guard trackingActive, - !isMovingUp, + isScrollingDown, !entry.isRead, !markedByScroll.contains(entryId), wasVisible.contains(entryId),