I created an app for daily workouts with Jetpack Compose. What I need is to display and manage the daily workouts:
Years(
response = { years ->
Log.d(TAG, years.toString())
Months(
response = { months ->
Log.d(TAG, years.toString())
Days(
response = { days ->
Log.d(TAG, days.toString())
Workouts(
response = { workouts ->
Log.d(TAG, workouts.toString())
}
)
}
)
}
)
}
)
First I read all years from Firestore, when a year is selected, I get all months, when a month is selected, I get all days, and when a day is selected I get all workouts. For all these requests I have added a real-time listener. When I display the data, everything works pretty fine, however, if I delete a workout, not only the list of workouts is recomposed, but all the other composables. For example, if I delete a workout, I get all previous logs, for days, months, and years along with the workouts. How can I stop the previous logs from being displayed?
P.S. In my ViewModel I get the data like:
var yearsResponse by mutableStateOf<YearsResponse>(Loading)
private set
private fun getYears() = viewModelScope.launch {
repo.getYears().collect { response ->
yearsResponse = response
}
}