Updated on 2026-08-14
This commit is contained in:
parent
dd11f56a38
commit
62b7fbda75
2 changed files with 43 additions and 45 deletions
|
|
@ -191,7 +191,7 @@ class OnboardingWalletFragment :
|
|||
}
|
||||
}
|
||||
|
||||
internal fun loadImageIntoImageView(uri: Uri?, view: ImageView) {
|
||||
private fun loadImageIntoImageView(uri: Uri?, view: ImageView) {
|
||||
view.load(uri) {
|
||||
placeholder(R.drawable.card_placeholder_black)
|
||||
error(R.drawable.card_placeholder_black)
|
||||
|
|
@ -412,7 +412,7 @@ class OnboardingWalletFragment :
|
|||
animator.showWriteBackupCard(state, cardNumber)
|
||||
}
|
||||
|
||||
internal fun showSuccess() = with(binding) {
|
||||
private fun showSuccess() = with(binding) {
|
||||
toolbar.title = getString(R.string.onboarding_done_header)
|
||||
tvHeader.text = getText(R.string.onboarding_done_header)
|
||||
|
||||
|
|
@ -427,9 +427,7 @@ class OnboardingWalletFragment :
|
|||
layoutButtonsCommon.btnWalletAlternativeAction.hide()
|
||||
layoutButtonsCommon.btnWalletMainAction.setOnClickListener {
|
||||
showConfetti(false)
|
||||
lifecycleScope.launch {
|
||||
store.dispatch(OnboardingWalletAction.FinishOnboarding(lifecycleCoroutineScope = lifecycleScope))
|
||||
}
|
||||
store.dispatch(OnboardingWalletAction.FinishOnboarding(lifecycleCoroutineScope = lifecycleScope))
|
||||
}
|
||||
|
||||
animator.showSuccess {
|
||||
|
|
|
|||
|
|
@ -1012,21 +1012,31 @@ internal class WalletViewModel @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
private fun initAndSetupWc(tokenListFlow: SharedFlow<Either<TokenListError, TokenList>>, wallet: UserWallet) {
|
||||
initWalletConnectForWallet(wallet)
|
||||
tokenListFlow
|
||||
.filter(::filterLoadedTokenList)
|
||||
.take(1)
|
||||
.onEach {
|
||||
it.onRight {
|
||||
setupWalletConnectOnWallet(wallet)
|
||||
}
|
||||
private fun initAndSetupWc(tokenListFlow: MaybeTokenListFlow, wallet: UserWallet) {
|
||||
viewModelScope
|
||||
.launch(dispatchers.main) {
|
||||
initWalletConnectForWallet(wallet)
|
||||
|
||||
tokenListFlow
|
||||
.filterLoadedTokenList()
|
||||
.take(count = 1)
|
||||
.collect { setupWalletConnectOnWallet(wallet) }
|
||||
}
|
||||
.flowOn(dispatchers.io)
|
||||
.launchIn(viewModelScope)
|
||||
.saveIn(updateWcJobHolder)
|
||||
}
|
||||
|
||||
private fun initWalletConnectForWallet(userWallet: UserWallet) {
|
||||
reduxStateHolder.dispatch(
|
||||
action = WalletConnectActions.New.Initialize(userWallet = userWallet),
|
||||
)
|
||||
}
|
||||
|
||||
private fun setupWalletConnectOnWallet(userWallet: UserWallet) {
|
||||
reduxStateHolder.dispatch(
|
||||
action = WalletConnectActions.New.SetupUserChains(userWallet = userWallet),
|
||||
)
|
||||
}
|
||||
|
||||
private fun isSingleWalletWithTokens(userWallet: UserWallet): Boolean {
|
||||
return userWallet.scanResponse.walletData?.token != null && !userWallet.isMultiCurrency
|
||||
}
|
||||
|
|
@ -1035,23 +1045,23 @@ internal class WalletViewModel @Inject constructor(
|
|||
return !this.any { it.value is CryptoCurrencyStatus.Loading }
|
||||
}
|
||||
|
||||
private fun filterLoadedTokenList(either: Either<TokenListError, TokenList>): Boolean {
|
||||
return either.fold(
|
||||
ifRight = { list ->
|
||||
when (list) {
|
||||
is TokenList.Ungrouped -> {
|
||||
list.currencies.isAllCurrenciesLoaded()
|
||||
private fun MaybeTokenListFlow.filterLoadedTokenList(): MaybeTokenListFlow {
|
||||
return filter { either ->
|
||||
either.fold(
|
||||
ifRight = { list ->
|
||||
when (list) {
|
||||
is TokenList.Ungrouped -> {
|
||||
list.currencies.isAllCurrenciesLoaded()
|
||||
}
|
||||
is TokenList.GroupedByNetwork -> {
|
||||
list.groups.flatMap(NetworkGroup::currencies).isAllCurrenciesLoaded()
|
||||
}
|
||||
else -> false
|
||||
}
|
||||
is TokenList.GroupedByNetwork -> {
|
||||
list.groups.flatMap { group -> group.currencies }.isAllCurrenciesLoaded()
|
||||
}
|
||||
else -> {
|
||||
false
|
||||
}
|
||||
}
|
||||
},
|
||||
ifLeft = { false },
|
||||
)
|
||||
},
|
||||
ifLeft = { false },
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun List<CryptoCurrencyStatus>.hasNonZeroWallets(): Boolean {
|
||||
|
|
@ -1187,18 +1197,6 @@ internal class WalletViewModel @Inject constructor(
|
|||
)
|
||||
}
|
||||
|
||||
private fun initWalletConnectForWallet(userWallet: UserWallet) {
|
||||
reduxStateHolder.dispatch(
|
||||
WalletConnectActions.New.Initialize(userWallet = userWallet),
|
||||
)
|
||||
}
|
||||
|
||||
private fun setupWalletConnectOnWallet(userWallet: UserWallet) {
|
||||
reduxStateHolder.dispatch(
|
||||
WalletConnectActions.New.SetupUserChains(userWallet = userWallet),
|
||||
)
|
||||
}
|
||||
|
||||
private fun getWallet(index: Int): UserWallet {
|
||||
return requireNotNull(
|
||||
value = wallets.getOrNull(index),
|
||||
|
|
@ -1214,4 +1212,6 @@ internal class WalletViewModel @Inject constructor(
|
|||
}
|
||||
|
||||
private fun getCardTypeResolver(index: Int): CardTypesResolver = getWallet(index).scanResponse.cardTypesResolver
|
||||
}
|
||||
}
|
||||
|
||||
typealias MaybeTokenListFlow = Flow<Either<TokenListError, TokenList>>
|
||||
Loading…
Add table
Add a link
Reference in a new issue