summaryrefslogtreecommitdiff
path: root/wallet/src/main/java/net/taler/wallet/MainViewModel.kt
diff options
context:
space:
mode:
authorTorsten Grote <t@grobox.de>2020-05-12 15:26:44 -0300
committerTorsten Grote <t@grobox.de>2020-05-15 14:26:41 -0300
commite74f39ee86f32b4e0324405af1f0c7be061fb372 (patch)
tree484a9e2f6ad3d8d6c9662ff5f41c6f254d218b30 /wallet/src/main/java/net/taler/wallet/MainViewModel.kt
parent4a6630d1d147ae35358272dc5222964831c234ab (diff)
downloadtaler-android-e74f39ee86f32b4e0324405af1f0c7be061fb372.tar.gz
taler-android-e74f39ee86f32b4e0324405af1f0c7be061fb372.tar.bz2
taler-android-e74f39ee86f32b4e0324405af1f0c7be061fb372.zip
[wallet] separate history and transactions UI
The history with its JSON payload is only shown in dev mode while the transactions are prepared to move to the new API.
Diffstat (limited to 'wallet/src/main/java/net/taler/wallet/MainViewModel.kt')
-rw-r--r--wallet/src/main/java/net/taler/wallet/MainViewModel.kt19
1 files changed, 12 insertions, 7 deletions
diff --git a/wallet/src/main/java/net/taler/wallet/MainViewModel.kt b/wallet/src/main/java/net/taler/wallet/MainViewModel.kt
index 230c310..b880036 100644
--- a/wallet/src/main/java/net/taler/wallet/MainViewModel.kt
+++ b/wallet/src/main/java/net/taler/wallet/MainViewModel.kt
@@ -23,11 +23,13 @@ import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.distinctUntilChanged
+import androidx.lifecycle.viewModelScope
import com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.module.kotlin.KotlinModule
import net.taler.common.Amount
import net.taler.wallet.backend.WalletBackendApi
+import net.taler.wallet.history.DevHistoryManager
import net.taler.wallet.payment.PaymentManager
import net.taler.wallet.pending.PendingOperationsManager
import net.taler.wallet.refund.RefundManager
@@ -70,13 +72,13 @@ class MainViewModel(val app: Application) : AndroidViewModel(app) {
loadBalances()
if (payload.optString("type") in transactionNotifications) {
// update transaction list
- // TODO do this in a better way
- transactionManager.showAll.value?.let {
- transactionManager.showAll.postValue(it)
- }
+ transactionManager.loadTransactions()
+ }
+ // refresh pending ops and history with each notification
+ if (devMode.value == true) {
+ pendingOperationsManager.getPending()
+ historyManager.loadHistory()
}
- // refresh pending ops with each notification
- if (devMode.value == true) pendingOperationsManager.getPending()
}
}
@@ -88,7 +90,10 @@ class MainViewModel(val app: Application) : AndroidViewModel(app) {
val paymentManager = PaymentManager(walletBackendApi, mapper)
val pendingOperationsManager: PendingOperationsManager =
PendingOperationsManager(walletBackendApi)
- val transactionManager: TransactionManager = TransactionManager(walletBackendApi, mapper)
+ val historyManager: DevHistoryManager =
+ DevHistoryManager(walletBackendApi, viewModelScope, mapper)
+ val transactionManager: TransactionManager =
+ TransactionManager(walletBackendApi, viewModelScope, mapper)
val refundManager = RefundManager(walletBackendApi)
override fun onCleared() {