Updated on 2026-08-14
This commit is contained in:
parent
3af4539567
commit
06be58d883
3 changed files with 61 additions and 20 deletions
|
|
@ -62,6 +62,7 @@ import com.tangem.domain.tokens.model.analytics.TokenReceiveCopyActionSource
|
|||
import com.tangem.domain.tokens.model.analytics.TokenReceiveNewAnalyticsEvent
|
||||
import com.tangem.domain.tokens.model.analytics.TokenScreenAnalyticsEvent
|
||||
import com.tangem.domain.tokens.model.analytics.TokenScreenAnalyticsEvent.Companion.toReasonAnalyticsText
|
||||
import com.tangem.domain.tokens.model.analytics.TokenScreenAnalyticsEvent.DetailsScreenOpened.TokenBalance
|
||||
import com.tangem.domain.tokens.model.analytics.TokenSwapPromoAnalyticsEvent
|
||||
import com.tangem.domain.transaction.error.AssociateAssetError
|
||||
import com.tangem.domain.transaction.error.IncompleteTransactionError
|
||||
|
|
@ -90,6 +91,7 @@ import com.tangem.features.tokenreceive.TokenReceiveFeatureToggle
|
|||
import com.tangem.features.txhistory.entity.TxHistoryContentUpdateEmitter
|
||||
import com.tangem.utils.Provider
|
||||
import com.tangem.utils.coroutines.*
|
||||
import com.tangem.utils.extensions.isZero
|
||||
import kotlinx.collections.immutable.PersistentList
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
import kotlinx.coroutines.async
|
||||
|
|
@ -162,6 +164,7 @@ internal class TokenDetailsModel @Inject constructor(
|
|||
private val selectedAppCurrencyFlow: StateFlow<AppCurrency> = createSelectedAppCurrencyFlow()
|
||||
|
||||
private var cryptoCurrencyStatus: CryptoCurrencyStatus? = null
|
||||
private var isBalanceLoadedEventSent = false
|
||||
private var expressTxStatusTaskScheduler = SingleTaskScheduler<PersistentList<ExpressTransactionStateUM>>()
|
||||
|
||||
/** Transaction id to check for status */
|
||||
|
|
@ -207,9 +210,6 @@ internal class TokenDetailsModel @Inject constructor(
|
|||
val uiState: StateFlow<TokenDetailsState> = internalUiState
|
||||
|
||||
init {
|
||||
analyticsEventsHandler.send(
|
||||
event = TokenScreenAnalyticsEvent.DetailsScreenOpened(token = cryptoCurrency.symbol),
|
||||
)
|
||||
updateTopBarMenu()
|
||||
initButtons()
|
||||
updateContent()
|
||||
|
|
@ -326,6 +326,7 @@ internal class TokenDetailsModel @Inject constructor(
|
|||
.onEach { maybeCurrencyStatus ->
|
||||
internalUiState.value = stateFactory.getCurrencyLoadedBalanceState(maybeCurrencyStatus)
|
||||
maybeCurrencyStatus.onRight { status ->
|
||||
sendOneTimeBalanceLoadedAnalyticsEvent(status)
|
||||
cryptoCurrencyStatus = status
|
||||
updateButtons(currencyStatus = status)
|
||||
updateWarnings(status)
|
||||
|
|
@ -1122,6 +1123,44 @@ internal class TokenDetailsModel @Inject constructor(
|
|||
)
|
||||
}
|
||||
|
||||
private fun sendOneTimeBalanceLoadedAnalyticsEvent(cryptoCurrencyStatus: CryptoCurrencyStatus?) {
|
||||
if (isBalanceLoadedEventSent || cryptoCurrencyStatus == null) return
|
||||
|
||||
val tokenBalance = when (val value = cryptoCurrencyStatus.value) {
|
||||
is CryptoCurrencyStatus.Custom,
|
||||
is CryptoCurrencyStatus.Loaded,
|
||||
is CryptoCurrencyStatus.NoQuote,
|
||||
-> {
|
||||
if (value.sources.networkSource.isActual()) {
|
||||
val amount = value.amount
|
||||
if (amount != null && !amount.isZero()) {
|
||||
TokenBalance.Full
|
||||
} else {
|
||||
TokenBalance.Empty
|
||||
}
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
is CryptoCurrencyStatus.NoAccount,
|
||||
is CryptoCurrencyStatus.MissedDerivation,
|
||||
-> TokenBalance.NoAddress
|
||||
|
||||
is CryptoCurrencyStatus.NoAmount,
|
||||
is CryptoCurrencyStatus.Unreachable,
|
||||
-> TokenBalance.Error
|
||||
CryptoCurrencyStatus.Loading -> return
|
||||
}
|
||||
analyticsEventsHandler.send(
|
||||
event = TokenScreenAnalyticsEvent.DetailsScreenOpened(
|
||||
blockchain = cryptoCurrency.network.name,
|
||||
token = cryptoCurrency.symbol,
|
||||
tokenBalance = tokenBalance,
|
||||
),
|
||||
)
|
||||
isBalanceLoadedEventSent = true
|
||||
}
|
||||
|
||||
private companion object {
|
||||
const val EXPRESS_STATUS_UPDATE_DELAY = 10_000L
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue