Updated on 2026-08-14

This commit is contained in:
Tangem 2023-10-10 14:50:19 +08:00
parent e2791d9b35
commit afcde269ce
24 changed files with 243 additions and 131 deletions

View file

@ -106,6 +106,7 @@ internal class WalletViewModel @Inject constructor(
private val shouldShowSaveWalletScreenUseCase: ShouldShowSaveWalletScreenUseCase,
private val canUseBiometryUseCase: CanUseBiometryUseCase,
private val shouldSaveUserWalletsUseCase: ShouldSaveUserWalletsUseCase,
private val shouldSaveUserWalletsSyncUseCase: ShouldSaveUserWalletsSyncUseCase,
private val isBalanceHiddenUseCase: IsBalanceHiddenUseCase,
private val listenToFlipsUseCase: ListenToFlipsUseCase,
private val removeCurrencyUseCase: RemoveCurrencyUseCase,
@ -182,12 +183,18 @@ internal class WalletViewModel @Inject constructor(
}
}
getWalletsUseCase()
.flowWithLifecycle(owner.lifecycle)
.distinctUntilChanged()
.onEach(::updateWallets)
.flowOn(dispatchers.io)
.launchIn(viewModelScope)
viewModelScope.launch(dispatchers.io) {
shouldSaveUserWalletsUseCase()
.flowWithLifecycle(owner.lifecycle)
.collectLatest {
getWalletsUseCase()
.flowWithLifecycle(owner.lifecycle)
.distinctUntilChanged()
.onEach(::updateWallets)
.flowOn(dispatchers.io)
.launchIn(viewModelScope)
}
}
isBalanceHiddenUseCase()
.flowWithLifecycle(owner.lifecycle)
@ -274,7 +281,7 @@ internal class WalletViewModel @Inject constructor(
override fun onBackClick() {
viewModelScope.launch(dispatchers.main) {
router.popBackStack(screen = if (shouldSaveUserWalletsUseCase()) AppScreen.Welcome else AppScreen.Home)
router.popBackStack(screen = if (shouldSaveUserWalletsSyncUseCase()) AppScreen.Welcome else AppScreen.Home)
}
}