[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-taler-android] 08/15: [wallet] Cache currencySpec in loadBalances
From: |
gnunet |
Subject: |
[taler-taler-android] 08/15: [wallet] Cache currencySpec in loadBalances() |
Date: |
Wed, 27 Mar 2024 18:27:11 +0100 |
This is an automated email from the git hooks/post-receive script.
torsten-grote pushed a commit to branch master
in repository taler-android.
commit 8d56c1db12b80288fca092d97009ae74de36fffb
Author: Iván Ávalos <avalos@disroot.org>
AuthorDate: Wed Mar 13 12:48:44 2024 -0600
[wallet] Cache currencySpec in loadBalances()
(cherry picked from commit cd7cd4c79b727f470bed3f8ecff0fa4790beee57)
---
.../main/java/net/taler/wallet/balances/BalanceManager.kt | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/wallet/src/main/java/net/taler/wallet/balances/BalanceManager.kt
b/wallet/src/main/java/net/taler/wallet/balances/BalanceManager.kt
index b2e6be3..4558396 100644
--- a/wallet/src/main/java/net/taler/wallet/balances/BalanceManager.kt
+++ b/wallet/src/main/java/net/taler/wallet/balances/BalanceManager.kt
@@ -65,6 +65,8 @@ class BalanceManager(
private val mState = MutableLiveData<BalanceState>(BalanceState.None)
val state: LiveData<BalanceState> = mState.distinctUntilChanged()
+ private var currencySpecs: Map<ScopeInfo, CurrencySpecification?>? = null
+
@UiThread
fun loadBalances() {
mState.value = BalanceState.Loading
@@ -77,10 +79,17 @@ class BalanceManager(
response.onSuccess {
mState.postValue(BalanceState.Success(it.balances))
scope.launch {
- // Get currency spec for all balances)
+ // Get currency spec for all balances
+ if (currencySpecs == null) {
+ currencySpecs = it.balances.associate { balance ->
+ val spec =
getCurrencySpecification(balance.scopeInfo)
+ balance.scopeInfo to spec
+ }
+ }
+
mState.postValue(
BalanceState.Success(it.balances.map { balance ->
- val spec =
getCurrencySpecification(balance.scopeInfo)
+ val spec = currencySpecs?.get(balance.scopeInfo)
balance.copy(
available = balance.available.withSpec(spec),
pendingIncoming =
balance.pendingIncoming.withSpec(spec),
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [taler-taler-android] branch master updated (39b6926 -> 4af27e7), gnunet, 2024/03/27
- [taler-taler-android] 04/15: [wallet] Balance layout improvements, gnunet, 2024/03/27
- [taler-taler-android] 05/15: [wallet] Display transactions by scopeInfo instead of currency, gnunet, 2024/03/27
- [taler-taler-android] 02/15: [wallet] DD51: enrich some tx amounts with currencySpecification, gnunet, 2024/03/27
- [taler-taler-android] 14/15: [wallet] Use Backend.json instead of Json, gnunet, 2024/03/27
- [taler-taler-android] 07/15: [wallet] Set input digits of some amount inputs, gnunet, 2024/03/27
- [taler-taler-android] 01/15: [wallet] DD51: initial rendering based on currency spec, gnunet, 2024/03/27
- [taler-taler-android] 03/15: [wallet] DD51: enrich manual withdrawal amounts with currencySpecification, gnunet, 2024/03/27
- [taler-taler-android] 15/15: [wallet] Use TransactionManager.selectedScope instead of passing around scopeInfo, gnunet, 2024/03/27
- [taler-taler-android] 08/15: [wallet] Cache currencySpec in loadBalances(),
gnunet <=
- [taler-taler-android] 10/15: [taler-android] Improve handling of currencies with no symbol, gnunet, 2024/03/27
- [taler-taler-android] 12/15: [wallet] Fix call to loadBalances() from non-UI thread, gnunet, 2024/03/27
- [taler-taler-android] 06/15: [wallet] Improve DD51 unit rendering and adapt tests accordingly, gnunet, 2024/03/27
- [taler-taler-android] 11/15: [wallet] Cache currency spec per scope info, gnunet, 2024/03/27
- [taler-taler-android] 13/15: [wallet] DD51'd more views, UX improvements and some fixes, gnunet, 2024/03/27
- [taler-taler-android] 09/15: [taler-android] Improved and refactored testToString test, gnunet, 2024/03/27