Updated on 2026-08-14
This commit is contained in:
parent
2957d6bdad
commit
fcc17181ad
1 changed files with 6 additions and 2 deletions
|
|
@ -58,6 +58,7 @@ import com.tangem.utils.coroutines.SingleTaskScheduler
|
|||
import com.tangem.utils.extensions.orZero
|
||||
import com.tangem.utils.isNullOrZero
|
||||
import com.tangem.utils.transformer.update
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.async
|
||||
import kotlinx.coroutines.awaitAll
|
||||
import kotlinx.coroutines.flow.*
|
||||
|
|
@ -110,6 +111,8 @@ internal class SwapAmountModel @Inject constructor(
|
|||
|
||||
private var isShowBestRateAnimation: Boolean = false
|
||||
|
||||
private var autoUpdateSubscriberJob: Job? = null
|
||||
|
||||
val uiState: StateFlow<SwapAmountUM>
|
||||
field = MutableStateFlow(params.amountUM)
|
||||
|
||||
|
|
@ -132,7 +135,6 @@ internal class SwapAmountModel @Inject constructor(
|
|||
subscribeOnAmountIgnoreReduceTriggerUpdates()
|
||||
subscribeOnReloadQuotesTriggerUpdates()
|
||||
subscribeOnBalanceHiddenUpdates()
|
||||
subscribeOnAutoupdateEnabling()
|
||||
}
|
||||
|
||||
fun onStart() {
|
||||
|
|
@ -140,10 +142,12 @@ internal class SwapAmountModel @Inject constructor(
|
|||
scope = modelScope,
|
||||
task = loadQuotesTask(),
|
||||
)
|
||||
subscribeOnAutoupdateEnabling()
|
||||
}
|
||||
|
||||
fun onStop() {
|
||||
quoteTaskScheduler.cancelTask()
|
||||
autoUpdateSubscriberJob?.cancel()
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
|
|
@ -484,7 +488,7 @@ internal class SwapAmountModel @Inject constructor(
|
|||
}
|
||||
|
||||
private fun subscribeOnAutoupdateEnabling() {
|
||||
swapAmountUpdateListener.autoUpdateTriggerFlow
|
||||
autoUpdateSubscriberJob = swapAmountUpdateListener.autoUpdateTriggerFlow
|
||||
.distinctUntilChanged()
|
||||
.onEach { isEnabled ->
|
||||
if (isEnabled) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue