-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(subscribeToPredictions): ensure old data present when merging in new data #596
Conversation
|
||
val predictions: StateFlow<PredictionsByStopJoinResponse?> = _predictions | ||
val predictionsFlow = | ||
predictions.map { it?.toPredictionsStreamDataResponse() }.debounce(0.1.seconds) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the ordering of map
vs. debounce
relevant?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh good point, I'll swap to the two to avoid excessive maps
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -61,7 +63,7 @@ fun subscribeToAlerts( | |||
val viewModel: AlertsViewModel = viewModel(factory = AlertsViewModel.Factory(alertsRepository)) | |||
|
|||
LifecycleResumeEffect(key1 = null) { | |||
viewModel.connect() | |||
CoroutineScope(Dispatchers.IO).launch { viewModel.connect() } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JackVCurtis added the use of Dipsatchers.IO in #557, and I mistakenly removed in #588.
This addresses some of the jankiness / lag while panning the map or scrolling the list of departures.
Applying across all channels.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
Summary
Ticket: 🤖 | Nearby | Predictions unavailable more than expected
What is this PR for?
Nearby Transit was getting stuck showing "Predictions Unavailable" For routes that had predictions, such as RL. Predictions reliably loaded in Stop Details, but not in Nearby Transit.
After adding debug logs, it seems the issue is that where we merge new predictions messages with the current state of predictions, the current state of predictions is out of date & often null, so we lose predictions from earlier messages. The docs for LiveData.getValue() mention
Whereas StateFlow:
iOS
android
Testing
What testing have you done?