[#1425] Improve Balances widget loader logic

- Closes #1425
- Changelog update
This commit is contained in:
Honza Rychnovský 2024-05-02 12:04:49 +02:00 committed by GitHub
parent a1cf59f9b2
commit 09febc6ff1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 5 deletions

View File

@ -13,6 +13,9 @@ directly impact users rather than highlighting other key architectural updates.*
- Delete Zashi feature has been added. It's accessible from the Advanced settings screen. It removes the wallet
secrets from Zashi and resets its state.
### Changed
- We've improved the visibility logic of the little loader that is part of the Balances widget
## [1.0 (638)] - 2024-04-26
### Fixed

View File

@ -31,6 +31,7 @@ import co.electriccoin.zcash.ui.common.model.OnboardingState
import co.electriccoin.zcash.ui.common.model.WalletRestoringState
import co.electriccoin.zcash.ui.common.model.WalletSnapshot
import co.electriccoin.zcash.ui.common.model.hasChangePending
import co.electriccoin.zcash.ui.common.model.hasValuePending
import co.electriccoin.zcash.ui.common.model.spendableBalance
import co.electriccoin.zcash.ui.common.model.totalBalance
import co.electriccoin.zcash.ui.preference.EncryptedPreferenceKeys
@ -251,13 +252,12 @@ class WalletViewModel(application: Application) : AndroidViewModel(application)
.map { snapshot ->
when {
// Show the loader only under these conditions:
// - Available balance is currently zero
// - Wallet has some ChangePending in progress
// - And Total balance is non-zero
// - Available balance is currently zero AND total balance is non-zero
// - And wallet has some ChangePending or ValuePending in progress
(
snapshot.spendableBalance().value == 0L &&
snapshot.hasChangePending() &&
snapshot.totalBalance().value > 0L
snapshot.totalBalance().value > 0L &&
(snapshot.hasChangePending() || snapshot.hasValuePending())
) -> {
BalanceState.Loading(
totalBalance = snapshot.totalBalance()