Splitfit
Splitfit copied to clipboard
Insights page flashes from "Nothing to display" to showing logged workouts
- [x] I have read the contribution guidelines.
- [x] I am using the latest version.
Describe the bug When I go to look at my logged workouts, the page displays a "Nothing to show" screen for a split second before it displays my logged workouts. I assume it's not trying to wait and load data before displaying the "nothing to show" screen
To Reproduce Steps to reproduce the behavior:
- Go to insights (when you have at least one workout logged)
- The screen should flash "nothing to show"
Expected behavior Perhaps show a blank screen to begin with and then display "nothing to show" or the list of logged workouts, instead of showing "nothing to show" before you have loaded (or tried to load) logged workouts.
Screenshots / Screen recordings If applicable, add screenshots or screen recordings to help explain your problem.
Smartphone (please complete the following information):
- Device: OnePlus 6
- Android version: Android 10
Additional notes:
I'm not a Kotlin dev but if this is a simple fix I could try my hand at fixing it, just point me in the correct direction with a few instructions and I'll give it a go.
woops. Thanks for the bug report. If you'd like to try fixing it, here's the source of the bug:
https://github.com/noahjutz/Splitfit/blob/90886ee6a0e82aeeaed256e1d64a3a9177315163/app/src/main/java/com/noahjutz/splitfit/ui/workout/insights/WorkoutInsights.kt#L62-L65
workouts
is initially an empty list, which causes NothingHereYet
to be displayed. A possible solution would be to make it null
initially, in order to differentiate the state of loading with the state of no results.
I'm not a huge fan of that solution since now we have to handle that workouts
is nullable. Another solution could be to create a sealed class for the state of the screen in its ViewModel
:
sealed class State {
object Loading : State()
data class Found(val workouts: List<Workout>) : State()
object Empty : State()
}
A value of type MutableStateFlow<State>
could be declared in the ViewModel
and listened to from the composable.