Updated on 2026-08-14

This commit is contained in:
Tangem 2026-06-03 16:38:52 +05:00
commit 4e533c14ef
3 changed files with 19 additions and 17 deletions

View file

@ -15,8 +15,7 @@ import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.flow.onEmpty
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.onStart
private const val TAG = "PaymentAccountStatusProducer"
@ -38,10 +37,20 @@ internal class DefaultPaymentAccountStatusProducer @AssistedInject constructor(
logger.i("[${params.userWalletId}] produce() called")
return paymentAccountStatusesStore.get(userWalletId = params.userWalletId)
.onStart { logger.i("[${params.userWalletId}] flow subscribed to store") }
.onEach { logger.i("[${params.userWalletId}] flow emits statusType=${it.value::class.simpleName}") }
.onEmpty {
logger.i("[${params.userWalletId}] onEmpty triggered: emitting NotCreated fallback")
emit(value = AccountStatus.Payment(account, PaymentAccountStatusValue.NotCreated))
.map { status ->
if (status != null) {
logger.i("[${params.userWalletId}] flow emits statusType=${status.value::class.simpleName}")
AccountStatus.Payment(
account = account,
value = status.value,
)
} else {
logger.i("[${params.userWalletId}] status is null: emitting Empty fallback")
AccountStatus.Payment(
account = account,
value = PaymentAccountStatusValue.Empty,
)
}
}
.flowOn(dispatchers.default)
}

View file

@ -13,11 +13,7 @@ import com.tangem.utils.coroutines.AppCoroutineScope
import com.tangem.utils.coroutines.runSuspendCatching
import com.tangem.utils.logging.TangemLogger
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.firstOrNull
import kotlinx.coroutines.flow.mapNotNull
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.flow.onStart
import kotlinx.coroutines.flow.*
import kotlinx.coroutines.launch
internal typealias WalletIdWithPaymentStatus = Map<String, AccountStatus.Payment>
@ -65,7 +61,7 @@ internal class PaymentAccountStatusesStore(
}
}
fun get(userWalletId: UserWalletId): Flow<AccountStatus.Payment> {
fun get(userWalletId: UserWalletId): Flow<AccountStatus.Payment?> {
return runtimeStore.get()
.onStart { logger.i("get($userWalletId): subscribed to runtimeStore") }
.onEach { map ->
@ -74,10 +70,7 @@ internal class PaymentAccountStatusesStore(
"hasEntry=${map.containsKey(userWalletId.stringValue)}",
)
}
.mapNotNull { it[userWalletId.stringValue] }
.onEach { status ->
logger.i("get($userWalletId): emitting statusType=${status.value::class.simpleName}")
}
.map { it[userWalletId.stringValue] }
}
suspend fun getSyncOrNull(userWalletId: UserWalletId): AccountStatus.Payment? {

View file

@ -5,7 +5,7 @@
# https://github.com/tangem/tangem-sdk-android/
# https://github.com/tangem/vico
tangemBlockchainSdk = "releases-5.38-1542"
tangemBlockchainSdk = "releases-5.38-1543"
#tangemBlockchainSdk = "0.0.1" # Keep it! - used for local builds
tangemCardSdk = "releases-5.38-615"
#tangemCardSdk = "0.0.1" # Keep it! - used for local builds ^