mitchtabian / Open-API-Android-App

Kotlin, MVI, Hilt, Retrofit2, Coroutines, Room Persistence, REST API, Token Authentication
692 stars 231 forks source link

duplicate dialog #34

Closed razaghimahdi closed 3 years ago

razaghimahdi commented 3 years ago

so sometimes i get duplicate dialog, i got logging and it seems queue list returns duplicate in observers, why is that? how should i to resolve that?

razaghimahdi commented 3 years ago

Boys and Girls, remember that if we use this way to change value of state:

val update = getCurrentViewStateOrNew()
                update.queue = queue
                setViewState(update)

it will make things duplicate, for example i have an Event which inside that was another Event so when dialog pop up it would be 3 or 2 time duplicate, so use this way as mitch already said:

this.state.value = state.copy(queue = queue)