Skip to content

HomeViewModel: replace pendingMapFocus boolean pair with a PendingFocus data class#1917

Merged
bmander merged 1 commit into
mainfrom
fix/1903-pending-focus-data-class
Jul 16, 2026
Merged

HomeViewModel: replace pendingMapFocus boolean pair with a PendingFocus data class#1917
bmander merged 1 commit into
mainfrom
fix/1903-pending-focus-data-class

Conversation

@bmander

@bmander bmander commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Fixes HomeViewModel: replace the pendingMapFocus boolean pair with a PendingFocus data class (stale-flag bug) #1903 (2026-07-16 debt review, finding 3, severity high — live bug).
  • pendingMapFocus / preserveViewportForPendingMapFocus had to be kept in sync by hand: markPendingMapFocus() set the first but never reset the second, so a stalled back-restore (arrivals never load, e.g. a network failure) followed by revealStop() (search/nav) could inherit a stale preserveViewport=true and suppress the recenter/frame on the newly revealed stop.
  • Replaces the boolean pair (plus the related animatePendingMapFocus) with one nullable PendingFocus data class, set atomically by markPendingMapFocus(animate, preserveViewport). Every call site (revealStop, applyInitialFocus, restoreMapAfterBack, clearMapFocus, onArrivalsLoaded) now goes through the single latch, so the invalid stale-flag state is no longer representable.

Test plan

  • ./gradlew :onebusaway-android:compileObaGoogleDebugKotlin -PwarningsAsErrors=true — builds clean under the CI strict-warnings gate.
  • ./gradlew :onebusaway-android:testObaGoogleDebugUnitTest --tests "org.onebusaway.android.ui.home.HomeViewModelTest" — passes (existing coverage for markPendingMapFocus/onArrivalsLoaded unaffected, default params preserve compatibility).

🤖 Generated with Claude Code

…1903)

markPendingMapFocus() previously set pendingMapFocus/animatePendingMapFocus
but left preserveViewportForPendingMapFocus untouched, so revealStop() after
a stalled back-restore (arrivals never loaded) could inherit a stale
preserveViewport=true and suppress the recenter/frame on the newly revealed
stop. A single nullable PendingFocus latch makes every mark atomic, so the
stale flag can no longer survive across an unrelated focus change.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@bmander
bmander merged commit b583f9e into main Jul 16, 2026
2 checks passed
@bmander
bmander deleted the fix/1903-pending-focus-data-class branch July 16, 2026 22:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HomeViewModel: replace the pendingMapFocus boolean pair with a PendingFocus data class (stale-flag bug)

1 participant