Updated on 2026-08-14
This commit is contained in:
parent
8b576c6492
commit
d9bbb09aef
8 changed files with 35 additions and 19 deletions
|
|
@ -54,8 +54,8 @@ private class CoilTimberLogger : Logger {
|
|||
|
||||
override fun log(tag: String, priority: Int, message: String?, throwable: Throwable?) {
|
||||
with(Timber.tag(COIL_LOG_TAG)) {
|
||||
throwable?.let { e -> e(e, message) }
|
||||
message?.let { msg -> d(msg) }
|
||||
if (throwable != null) e(throwable, message)
|
||||
if (message != null) d(message)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -41,8 +41,8 @@ object SimpleCancelableAlertDialog {
|
|||
context: Context,
|
||||
): AlertDialog {
|
||||
return MaterialAlertDialogBuilder(context, R.style.CustomMaterialDialog).apply {
|
||||
setTitle(titleRes?.let { context.getString(it) } ?: title)
|
||||
setMessage(messageRes?.let { context.getString(it) } ?: message)
|
||||
setTitle(if (titleRes != null) context.getString(titleRes) else title)
|
||||
setMessage(if (messageRes != null) context.getString(messageRes) else message)
|
||||
setPositiveButton(context.getText(primaryButtonRes)) { _, _ -> primaryButtonAction() }
|
||||
if (secondaryButtonRes != null) {
|
||||
setNegativeButton(context.getText(secondaryButtonRes)) { _, _ -> secondaryButtonAction() }
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import com.tangem.tap.domain.userWalletList.utils.toUserWallets
|
|||
import com.tangem.tap.domain.userWalletList.utils.updateWith
|
||||
import com.tangem.utils.Provider
|
||||
import com.tangem.utils.ProviderSuspend
|
||||
import com.tangem.utils.coroutines.runSuspendCatching
|
||||
import com.tangem.utils.extensions.indexOfFirstOrNull
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.update
|
||||
|
|
@ -149,7 +150,7 @@ internal class DefaultUserWalletsListRepository(
|
|||
val encryptionKey = userWallet.encryptionKey
|
||||
?: raise(SetLockError.UserWalletLocked)
|
||||
|
||||
runCatching {
|
||||
runSuspendCatching {
|
||||
userWalletEncryptionKeysRepository.save(
|
||||
encryptionKey = UserWalletEncryptionKey(
|
||||
walletId = userWalletId,
|
||||
|
|
@ -232,7 +233,7 @@ internal class DefaultUserWalletsListRepository(
|
|||
val encryptionKey = requestPasswordRecursive(
|
||||
hotWalletId = userWallet.hotWalletId,
|
||||
block = { password ->
|
||||
runCatching {
|
||||
runSuspendCatching {
|
||||
userWalletEncryptionKeysRepository.getEncryptedWithPassword(userWalletId, password)
|
||||
}.onFailure {
|
||||
raise(UnlockWalletError.UnableToUnlock)
|
||||
|
|
@ -288,7 +289,7 @@ internal class DefaultUserWalletsListRepository(
|
|||
|
||||
override suspend fun unlockAllWallets(): Either<UnlockWalletError, Unit> = either {
|
||||
val userWallets = userWalletsSync()
|
||||
val biometricKeys = runCatching {
|
||||
val biometricKeys = runSuspendCatching {
|
||||
userWalletEncryptionKeysRepository.getAllBiometric()
|
||||
}.getOrElse {
|
||||
// TODO handle error properly [REDACTED_TASK_KEY]
|
||||
|
|
|
|||
|
|
@ -77,9 +77,13 @@ internal class WelcomeModel @Inject constructor(
|
|||
warning = warning,
|
||||
error = state.error
|
||||
?.takeIf { !it.silent && warning == null }
|
||||
?.let { e ->
|
||||
e.messageResId?.let { TextReference.Res(it) }
|
||||
?: TextReference.Str(e.customMessage)
|
||||
?.let { error ->
|
||||
val messageResId = error.messageResId
|
||||
if (messageResId != null) {
|
||||
TextReference.Res(messageResId)
|
||||
} else {
|
||||
TextReference.Str(error.customMessage)
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import com.tangem.domain.transaction.models.AssetRequirementsCondition
|
|||
import com.tangem.utils.Provider
|
||||
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
|
||||
import com.tangem.utils.coroutines.runCatching
|
||||
import com.tangem.utils.coroutines.runSuspendCatching
|
||||
import com.tangem.utils.isNullOrZero
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.firstOrNull
|
||||
|
|
@ -35,7 +36,7 @@ internal class DefaultRampManager(
|
|||
userWallet: UserWallet,
|
||||
cryptoCurrency: CryptoCurrency,
|
||||
): ScenarioUnavailabilityReason {
|
||||
val availabilityState = runCatching { getOnrampAvailableState(userWallet.walletId, cryptoCurrency) }
|
||||
val availabilityState = runSuspendCatching { getOnrampAvailableState(userWallet.walletId, cryptoCurrency) }
|
||||
.getOrNull()
|
||||
?: ExpressAvailabilityState.Error
|
||||
|
||||
|
|
@ -84,7 +85,7 @@ internal class DefaultRampManager(
|
|||
userWalletId: UserWalletId,
|
||||
cryptoCurrency: CryptoCurrency,
|
||||
): ScenarioUnavailabilityReason {
|
||||
val availabilityState = runCatching {
|
||||
val availabilityState = runSuspendCatching {
|
||||
getExchangeableState(userWalletId, cryptoCurrency)
|
||||
}.getOrNull() ?: ExpressAvailabilityState.Error
|
||||
return availabilityState.toReason(cryptoCurrency.name)
|
||||
|
|
|
|||
|
|
@ -19,6 +19,16 @@ suspend fun <R> waitForDelay(delay: Long, block: suspend CoroutineScope.() -> R)
|
|||
actionInvoke.await()
|
||||
}
|
||||
|
||||
suspend inline fun <T, R> T.runSuspendCatching(block: suspend T.() -> R): Result<R> {
|
||||
return try {
|
||||
Result.success(block())
|
||||
} catch (e: CancellationException) {
|
||||
throw e
|
||||
} catch (e: Throwable) {
|
||||
Result.failure(e)
|
||||
}
|
||||
}
|
||||
|
||||
class Debouncer {
|
||||
|
||||
private var debounceJob: Job? = null
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ class ExcludedBlockchains @Inject internal constructor(
|
|||
private val excludedBlockchainsManager: ExcludedBlockchainsManager,
|
||||
) : Set<Blockchain> {
|
||||
|
||||
private val excludedBlockchains: Set<Blockchain> by lazy(mode = LazyThreadSafetyMode.NONE) {
|
||||
private val excludedBlockchainsSet: Set<Blockchain> by lazy(mode = LazyThreadSafetyMode.NONE) {
|
||||
excludedBlockchainsManager.excludedBlockchainsIds.fold(mutableSetOf()) { acc, blockchainId ->
|
||||
val blockchain = Blockchain.fromId(blockchainId)
|
||||
acc.add(blockchain)
|
||||
|
|
@ -22,7 +22,7 @@ class ExcludedBlockchains @Inject internal constructor(
|
|||
}
|
||||
|
||||
override val size: Int
|
||||
get() = excludedBlockchains.size
|
||||
get() = excludedBlockchainsSet.size
|
||||
|
||||
@TestOnly
|
||||
constructor() : this(
|
||||
|
|
@ -32,11 +32,11 @@ class ExcludedBlockchains @Inject internal constructor(
|
|||
},
|
||||
)
|
||||
|
||||
override fun contains(element: Blockchain): Boolean = excludedBlockchains.contains(element)
|
||||
override fun contains(element: Blockchain): Boolean = excludedBlockchainsSet.contains(element)
|
||||
|
||||
override fun containsAll(elements: Collection<Blockchain>): Boolean = excludedBlockchains.containsAll(elements)
|
||||
override fun containsAll(elements: Collection<Blockchain>): Boolean = excludedBlockchainsSet.containsAll(elements)
|
||||
|
||||
override fun isEmpty(): Boolean = excludedBlockchains.isEmpty()
|
||||
override fun isEmpty(): Boolean = excludedBlockchainsSet.isEmpty()
|
||||
|
||||
override fun iterator(): Iterator<Blockchain> = excludedBlockchains.iterator()
|
||||
override fun iterator(): Iterator<Blockchain> = excludedBlockchainsSet.iterator()
|
||||
}
|
||||
|
|
@ -1 +1 @@
|
|||
Subproject commit 193db8a0247a1f33574dcdd5f9ec4dab2c28ea73
|
||||
Subproject commit 92c1bfd3123f0b2fd9e5a80b9d69bbc17a6e1160
|
||||
Loading…
Add table
Add a link
Reference in a new issue