Updated on 2026-08-14
This commit is contained in:
parent
4d75db3cdd
commit
22dc2eb3e9
57 changed files with 931 additions and 258 deletions
|
|
@ -565,12 +565,11 @@ internal class SwapAmountModel @Inject constructor(
|
|||
(params as? SwapAmountComponentParams.AmountParams)?.callback?.resetSendWithSwapNavigation(
|
||||
data.shouldResetNavigation,
|
||||
)
|
||||
ensurePrimaryReady()
|
||||
initPairs(data.swapCurrencies, data.cryptoCurrency)
|
||||
uiState.update { amountUM ->
|
||||
if (amountUM is SwapAmountUM.Content) {
|
||||
initPairs(data.swapCurrencies, data.cryptoCurrency)
|
||||
amountUM.copy(
|
||||
isPrimaryButtonEnabled = false,
|
||||
)
|
||||
amountUM.copy(isPrimaryButtonEnabled = false)
|
||||
} else {
|
||||
amountUM
|
||||
}
|
||||
|
|
@ -579,6 +578,32 @@ internal class SwapAmountModel @Inject constructor(
|
|||
.launchIn(modelScope)
|
||||
}
|
||||
|
||||
/**
|
||||
* Forces the amount UI into the primary-ready [SwapAmountUM.Content] state using the current primary
|
||||
* status. Needed for the direct Send-with-Swap (Swap&Send) entry where the state can be [SwapAmountUM.Empty] and
|
||||
* the balance-`distinctUntilChanged` primary status flow won't re-emit to rebuild it. No-op when already Content.
|
||||
*/
|
||||
private suspend fun ensurePrimaryReady() {
|
||||
if (uiState.value is SwapAmountUM.Content) return
|
||||
val primaryCurrencyStatus = params.primaryCryptoCurrencyStatusFlow.value
|
||||
initCurrencies(primaryStatus = primaryCurrencyStatus, secondaryStatus = null)
|
||||
val isOnlyOneWallet = getWalletsUseCase.invokeSync().size == 1
|
||||
uiState.transformerUpdate(
|
||||
SwapAmountPrimaryReadyStateTransformer(
|
||||
userWallet = userWallet,
|
||||
primaryCryptoCurrencyStatus = primaryCurrencyStatus,
|
||||
appCurrency = appCurrency,
|
||||
swapDirection = swapDirection,
|
||||
clickIntents = this,
|
||||
isBalanceHidden = params.isBalanceHidingFlow.value,
|
||||
isShowBestRateAnimation = isShowBestRateAnimation,
|
||||
isSingleWallet = isOnlyOneWallet,
|
||||
isAccountsMode = params.isAccountModeFlow.value,
|
||||
account = params.accountFlow.value,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
private fun initPairs(swapCurrencies: SwapCurrencies, secondaryCryptoCurrency: CryptoCurrency?) {
|
||||
modelScope.launch {
|
||||
val secondaryCurrency = selectInitialPairUseCase(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue