Updated on 2026-08-14
This commit is contained in:
parent
2cfd260e31
commit
19bdc77d9f
4 changed files with 33 additions and 3 deletions
|
|
@ -27,7 +27,10 @@ sealed class FeeSelectorUM {
|
|||
override val isPrimaryButtonEnabled = false
|
||||
}
|
||||
|
||||
data class Error(val error: GetFeeError) : FeeSelectorUM() {
|
||||
data class Error(
|
||||
val error: GetFeeError,
|
||||
val isHidden: Boolean = false,
|
||||
) : FeeSelectorUM() {
|
||||
override val isPrimaryButtonEnabled = false
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -75,9 +75,14 @@ internal class FeeSelectorLogic @AssistedInject constructor(
|
|||
}
|
||||
|
||||
private fun loadFee() {
|
||||
if (uiState.value is FeeSelectorUM.Error) {
|
||||
return
|
||||
}
|
||||
|
||||
if (uiState.value !is FeeSelectorUM.Content) {
|
||||
uiState.update(FeeSelectorLoadingTransformer)
|
||||
}
|
||||
|
||||
modelScope.launch {
|
||||
callLoadFee()
|
||||
.fold(
|
||||
|
|
|
|||
|
|
@ -61,6 +61,10 @@ internal fun FeeSelectorBlockContent(
|
|||
onReadMoreClick: () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
if (state is FeeSelectorUM.Error && state.isHidden) {
|
||||
return
|
||||
}
|
||||
|
||||
Row(
|
||||
modifier = modifier
|
||||
.background(TangemTheme.colors.background.action)
|
||||
|
|
|
|||
|
|
@ -651,13 +651,13 @@ internal class SwapModel @Inject constructor(
|
|||
modelScope.launch { feeSelectorReloadTrigger.triggerUpdate() }
|
||||
}
|
||||
} else {
|
||||
feeSelectorRepository.state.value = FeeSelectorUM.Error(GetFeeError.UnknownError)
|
||||
feeSelectorRepository.state.value = FeeSelectorUM.Error(GetFeeError.UnknownError, isHidden = true)
|
||||
Timber.e("Accidentally empty quotes list")
|
||||
}
|
||||
},
|
||||
onError = { error ->
|
||||
Timber.e("Error when loading quotes: $error")
|
||||
feeSelectorRepository.state.value = FeeSelectorUM.Error(GetFeeError.UnknownError)
|
||||
feeSelectorRepository.state.value = FeeSelectorUM.Error(GetFeeError.UnknownError, isHidden = true)
|
||||
uiState = stateBuilder.addNotification(uiState, null) { startLoadingQuotesFromLastState() }
|
||||
},
|
||||
)
|
||||
|
|
@ -2016,6 +2016,10 @@ internal class SwapModel @Inject constructor(
|
|||
return Either.Left(GetFeeError.UnknownError)
|
||||
}
|
||||
|
||||
if (isPermissionNotificationShown()) {
|
||||
return Either.Left(GetFeeError.UnknownError)
|
||||
}
|
||||
|
||||
return swapInteractor.loadFeeForSwapTransaction(
|
||||
fromToken = fromToken,
|
||||
fromAccount = dataState.fromAccount,
|
||||
|
|
@ -2029,6 +2033,11 @@ internal class SwapModel @Inject constructor(
|
|||
}
|
||||
|
||||
override fun onResult(newState: FeeSelectorUM) {
|
||||
if (isPermissionNotificationShown()) {
|
||||
state.value = FeeSelectorUM.Error(GetFeeError.UnknownError, isHidden = true)
|
||||
return
|
||||
}
|
||||
|
||||
state.value = newState
|
||||
|
||||
// If fee currency is same as from currency, we need to reload quotes to update fee info
|
||||
|
|
@ -2050,6 +2059,11 @@ internal class SwapModel @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
private fun isPermissionNotificationShown(): Boolean {
|
||||
val permissionState = dataState.getCurrentLoadedSwapState()?.permissionState
|
||||
return permissionState != null && permissionState !is PermissionDataState.Empty
|
||||
}
|
||||
|
||||
override suspend fun loadFee(): Either<GetFeeError, TransactionFee> {
|
||||
val sendCardData =
|
||||
uiState.sendCardData as? SwapCardState.SwapCardData ?: return Either.Left(GetFeeError.UnknownError)
|
||||
|
|
@ -2063,6 +2077,10 @@ internal class SwapModel @Inject constructor(
|
|||
return Either.Left(GetFeeError.UnknownError)
|
||||
}
|
||||
|
||||
if (isPermissionNotificationShown()) {
|
||||
return Either.Left(GetFeeError.UnknownError)
|
||||
}
|
||||
|
||||
return swapInteractor.loadFeeForSwapTransaction(
|
||||
fromToken = fromToken,
|
||||
fromAccount = dataState.fromAccount,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue