fix: scroll direction check always failed — read prevMinY before write
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) <noreply@anthropic.com>
This commit is contained in:
@@ -69,17 +69,21 @@ struct EntryListView: View {
|
|||||||
guard entryHeight > 0 else { return }
|
guard entryHeight > 0 else { return }
|
||||||
|
|
||||||
// --- Scroll direction + activation ---
|
// --- 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
|
let delta = prev - newMinY // positive = scrolling down
|
||||||
if delta > 2 {
|
isScrollingDown = delta > 2
|
||||||
|
if isScrollingDown {
|
||||||
cumulativeDown += delta
|
cumulativeDown += delta
|
||||||
if cumulativeDown > activationThreshold {
|
if cumulativeDown > activationThreshold {
|
||||||
trackingActive = true
|
trackingActive = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Don't reset trackingActive on upward scroll —
|
} else {
|
||||||
// just don't mark anything. Keeps cumulative progress.
|
isScrollingDown = false
|
||||||
}
|
}
|
||||||
|
// Store AFTER reading previous value
|
||||||
lastKnownMinY[entryId] = newMinY
|
lastKnownMinY[entryId] = newMinY
|
||||||
|
|
||||||
// --- Visibility tracking ---
|
// --- Visibility tracking ---
|
||||||
@@ -92,11 +96,8 @@ struct EntryListView: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// --- Mark-as-read ---
|
// --- 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,
|
guard trackingActive,
|
||||||
!isMovingUp,
|
isScrollingDown,
|
||||||
!entry.isRead,
|
!entry.isRead,
|
||||||
!markedByScroll.contains(entryId),
|
!markedByScroll.contains(entryId),
|
||||||
wasVisible.contains(entryId),
|
wasVisible.contains(entryId),
|
||||||
|
|||||||
Reference in New Issue
Block a user