Updated on 2026-08-14
This commit is contained in:
parent
189cb19ff2
commit
55b6b57963
2 changed files with 14 additions and 9 deletions
|
|
@ -20,6 +20,7 @@ import dagger.assisted.Assisted
|
|||
import dagger.assisted.AssistedFactory
|
||||
import dagger.assisted.AssistedInject
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.SharedFlow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
|
|
@ -55,7 +56,11 @@ class SwapFeeSelectorBlockComponent @AssistedInject constructor(
|
|||
|
||||
init {
|
||||
params.repository.state
|
||||
.onEach(feeSelectorBlockComponent::updateState)
|
||||
.onEach { feeSelectorBlockComponent.updateState(it) }
|
||||
.launchIn(componentScope)
|
||||
|
||||
params.repository.forceUpdateState
|
||||
.onEach { feeSelectorBlockComponent.updateState(it) }
|
||||
.launchIn(componentScope)
|
||||
}
|
||||
|
||||
|
|
@ -68,6 +73,9 @@ class SwapFeeSelectorBlockComponent @AssistedInject constructor(
|
|||
val state: StateFlow<FeeSelectorUM>
|
||||
get() = MutableStateFlow<FeeSelectorUM>(FeeSelectorUM.Loading)
|
||||
|
||||
val forceUpdateState: SharedFlow<FeeSelectorUM>
|
||||
get() = MutableStateFlow<FeeSelectorUM>(FeeSelectorUM.Loading)
|
||||
|
||||
fun onResult(newState: FeeSelectorUM)
|
||||
|
||||
suspend fun loadFee(): Either<GetFeeError, TransactionFee>
|
||||
|
|
|
|||
|
|
@ -2325,6 +2325,8 @@ internal class SwapModel @Inject constructor(
|
|||
FeeSelectorUM.Error(GetFeeError.UnknownError, isHidden = true),
|
||||
)
|
||||
|
||||
override val forceUpdateState = MutableSharedFlow<FeeSelectorUM>()
|
||||
|
||||
override suspend fun loadFeeExtended(
|
||||
selectedToken: CryptoCurrencyStatus?,
|
||||
): Either<GetFeeError, TransactionFeeExtended> {
|
||||
|
|
@ -2357,18 +2359,13 @@ internal class SwapModel @Inject constructor(
|
|||
}
|
||||
|
||||
override fun onResult(newState: FeeSelectorUM) {
|
||||
if (isPermissionNotificationShown()) {
|
||||
state.value = FeeSelectorUM.Error(GetFeeError.UnknownError, isHidden = true)
|
||||
return
|
||||
}
|
||||
|
||||
if (newState is FeeSelectorUM.Error) {
|
||||
state.value = newState.copy(isHidden = true)
|
||||
modelScope.launch {
|
||||
forceUpdateState.emit(newState.copy(isHidden = true))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
state.value = newState
|
||||
|
||||
// If fee currency is same as from currency, we need to reload quotes to update fee info
|
||||
val isFeeCurrencySameAsFromCurrency = newState is FeeSelectorUM.Content &&
|
||||
dataState.fromCryptoCurrency?.currency?.id == newState.feeExtraInfo.feeCryptoCurrencyStatus.currency.id
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue