Skip to content

Commit

Permalink
fix(health-sdk): Make resetting the openBankState flow's PaymentSta…
Browse files Browse the repository at this point in the history
…te to NoAction non-cancellable

This makes sure that the `openBankState` flow is reset to `PaymentState.NoAction` also when the
`ReviewViewModel`'s scope is cancelled due to the client dimissing the `ReviewFragment` when they
receive `PaymentState.Success`.

IPC-290
  • Loading branch information
a-szotyori committed Jul 1, 2024
1 parent ab530fa commit 2831ca8
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ import androidx.lifecycle.LifecycleEventObserver
import androidx.savedstate.SavedStateRegistry
import androidx.savedstate.SavedStateRegistryOwner
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.NonCancellable
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import kotlinx.parcelize.Parcelize
import net.gini.android.core.api.Resource
import net.gini.android.core.api.models.Document
Expand Down Expand Up @@ -147,8 +149,10 @@ class GiniHealth(
internal fun setOpenBankState(state: PaymentState, scope: CoroutineScope) {
_openBankState.value = state
scope.launch {
delay(50)
_openBankState.value = PaymentState.NoAction
withContext(NonCancellable) {
delay(50)
_openBankState.value = PaymentState.NoAction
}
}
}

Expand Down

0 comments on commit 2831ca8

Please sign in to comment.