Updated on 2026-08-14
This commit is contained in:
parent
e4b1bf4e61
commit
64ba8f0170
5 changed files with 34 additions and 0 deletions
|
|
@ -8,4 +8,6 @@ interface SwapAmountUpdateTrigger {
|
|||
suspend fun triggerUpdateAmount(amountValue: String, isEnterInFiatSelected: Boolean)
|
||||
|
||||
suspend fun triggerQuoteReload()
|
||||
|
||||
suspend fun triggerAutoUpdateEnabled(isEnabled: Boolean)
|
||||
}
|
||||
|
|
@ -17,6 +17,8 @@ interface SwapAmountUpdateListener {
|
|||
val updateAmountTriggerFlow: Flow<Pair<String, Boolean>>
|
||||
|
||||
val reloadQuotesTriggerFlow: Flow<Unit>
|
||||
|
||||
val autoUpdateTriggerFlow: Flow<Boolean>
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -59,6 +61,9 @@ internal class DefaultSwapAmountUpdateTrigger @Inject constructor() :
|
|||
override val reloadQuotesTriggerFlow: Flow<Unit>
|
||||
field = MutableSharedFlow<Unit>()
|
||||
|
||||
override val autoUpdateTriggerFlow: Flow<Boolean>
|
||||
field = MutableSharedFlow<Boolean>()
|
||||
|
||||
override suspend fun triggerUpdateAmount(amountValue: String, isEnterInFiatSelected: Boolean) {
|
||||
updateAmountTriggerFlow.emit(amountValue to isEnterInFiatSelected)
|
||||
}
|
||||
|
|
@ -67,6 +72,10 @@ internal class DefaultSwapAmountUpdateTrigger @Inject constructor() :
|
|||
reloadQuotesTriggerFlow.emit(Unit)
|
||||
}
|
||||
|
||||
override suspend fun triggerAutoUpdateEnabled(isEnabled: Boolean) {
|
||||
autoUpdateTriggerFlow.emit(isEnabled)
|
||||
}
|
||||
|
||||
override suspend fun triggerReduceBy(reduceBy: ReduceByData) {
|
||||
reduceByTriggerFlow.emit(reduceBy)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -132,6 +132,7 @@ internal class SwapAmountModel @Inject constructor(
|
|||
subscribeOnAmountIgnoreReduceTriggerUpdates()
|
||||
subscribeOnReloadQuotesTriggerUpdates()
|
||||
subscribeOnBalanceHiddenUpdates()
|
||||
subscribeOnAutoupdateEnabling()
|
||||
}
|
||||
|
||||
fun onStart() {
|
||||
|
|
@ -482,6 +483,19 @@ internal class SwapAmountModel @Inject constructor(
|
|||
.launchIn(modelScope)
|
||||
}
|
||||
|
||||
private fun subscribeOnAutoupdateEnabling() {
|
||||
swapAmountUpdateListener.autoUpdateTriggerFlow
|
||||
.distinctUntilChanged()
|
||||
.onEach { isEnabled ->
|
||||
if (isEnabled) {
|
||||
startLoadingQuotesTask(isSilentReload = true)
|
||||
} else {
|
||||
quoteTaskScheduler.cancelTask()
|
||||
}
|
||||
}
|
||||
.launchIn(modelScope)
|
||||
}
|
||||
|
||||
private fun observeChooseSelectToken() {
|
||||
swapChooseTokenNetworkListener.swapChooseTokenNetworkResultFlow
|
||||
.onEach { data ->
|
||||
|
|
|
|||
|
|
@ -98,6 +98,7 @@ internal class SendWithSwapConfirmComponent @AssistedInject constructor(
|
|||
analyticsCategoryName = params.analyticsCategoryName,
|
||||
analyticsSendSource = params.analyticsSendSource,
|
||||
userWalletId = params.userWallet.walletId,
|
||||
bottomSheetShown = model::onFeeBottomSheetShown,
|
||||
),
|
||||
onResult = model::onFeeResult,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ import com.tangem.features.send.v2.api.subcomponents.destination.entity.Destinat
|
|||
import com.tangem.features.send.v2.api.subcomponents.feeSelector.FeeSelectorReloadTrigger
|
||||
import com.tangem.features.send.v2.api.subcomponents.notifications.SendNotificationsUpdateListener
|
||||
import com.tangem.features.send.v2.api.subcomponents.notifications.SendNotificationsUpdateTrigger
|
||||
import com.tangem.features.swap.v2.api.subcomponents.SwapAmountUpdateTrigger
|
||||
import com.tangem.features.swap.v2.impl.R
|
||||
import com.tangem.features.swap.v2.impl.amount.SwapAmountReduceTrigger
|
||||
import com.tangem.features.swap.v2.impl.amount.entity.SwapAmountUM
|
||||
|
|
@ -90,6 +91,7 @@ internal class SendWithSwapConfirmModel @Inject constructor(
|
|||
private val sendNotificationsUpdateListener: SendNotificationsUpdateListener,
|
||||
private val swapNotificationsUpdateListener: SwapNotificationsUpdateListener,
|
||||
private val swapAmountReduceTrigger: SwapAmountReduceTrigger,
|
||||
private val swapAmountUpdateTrigger: SwapAmountUpdateTrigger,
|
||||
private val feeSelectorReloadTrigger: FeeSelectorReloadTrigger,
|
||||
private val swapAlertFactory: SwapAlertFactory,
|
||||
private val appRouter: AppRouter,
|
||||
|
|
@ -211,6 +213,12 @@ internal class SendWithSwapConfirmModel @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
fun onFeeBottomSheetShown(isShown: Boolean) {
|
||||
modelScope.launch {
|
||||
swapAmountUpdateTrigger.triggerAutoUpdateEnabled(isEnabled = !isShown)
|
||||
}
|
||||
}
|
||||
|
||||
fun showEditAmount() {
|
||||
analyticsEventHandler.send(
|
||||
CommonSendAnalyticEvents.ScreenReopened(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue