From e74f39ee86f32b4e0324405af1f0c7be061fb372 Mon Sep 17 00:00:00 2001 From: Torsten Grote Date: Tue, 12 May 2020 15:26:44 -0300 Subject: [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. --- .../src/main/java/net/taler/wallet/MainViewModel.kt | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'wallet/src/main/java/net/taler/wallet/MainViewModel.kt') 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() { -- cgit v1.2.3