Insights page flashes from "Nothing to display" to showing logged workouts #81

Closed
by matt-auckland opened 6 months ago · 2 comments
matt-auckland commented 6 months ago (Migrated from github.com)
Owner

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:

  1. Go to insights (when you have at least one workout logged)
  2. 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.

- [x] I have read the [contribution guidelines](https://github.com/noahjutz/Splitfit/blob/master/CONTRIBUTING.md). - [x] I am using the [latest version](https://github.com/noahjutz/Splitfit/releases). **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: 1. Go to insights (when you have at least one workout logged) 2. 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.
noahjutz commented 6 months ago (Migrated from github.com)
Owner

woops. Thanks for the bug report. If you'd like to try fixing it, here's the source of the bug:

90886ee6a0/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.

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`: ```kt 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.
Owner

This will be fixed in the next update with the introduction of placeholders.

This will be fixed in the next update with the introduction of placeholders.
noahjutz closed this issue 3 weeks ago
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date

No due date set.

Dependencies

This issue currently doesn't have any dependencies.

Loading…
There is no content yet.