aboutsummaryrefslogtreecommitdiff
path: root/wallet/src
diff options
context:
space:
mode:
authorTorsten Grote <t@grobox.de>2020-04-27 09:17:25 -0300
committerTorsten Grote <t@grobox.de>2020-04-27 09:17:25 -0300
commit0d4d6358ac6db7e0a1e936ecfd70ec4bb3262846 (patch)
tree122d1c534a7e5e359619bbd61d1b571fd9288a30 /wallet/src
parentd284953c7f540ea15a99b8ae3d99c2bfb6d1ee6b (diff)
downloadtaler-android-0d4d6358ac6db7e0a1e936ecfd70ec4bb3262846.tar.gz
taler-android-0d4d6358ac6db7e0a1e936ecfd70ec4bb3262846.tar.bz2
taler-android-0d4d6358ac6db7e0a1e936ecfd70ec4bb3262846.zip
[wallet] refresh transactions when certain notifications arrive
Diffstat (limited to 'wallet/src')
-rw-r--r--wallet/src/main/java/net/taler/wallet/MainViewModel.kt15
1 files changed, 14 insertions, 1 deletions
diff --git a/wallet/src/main/java/net/taler/wallet/MainViewModel.kt b/wallet/src/main/java/net/taler/wallet/MainViewModel.kt
index 907278c..159540b 100644
--- a/wallet/src/main/java/net/taler/wallet/MainViewModel.kt
+++ b/wallet/src/main/java/net/taler/wallet/MainViewModel.kt
@@ -37,6 +37,12 @@ import org.json.JSONObject
const val TAG = "taler-wallet"
+private val transactionNotifications = listOf(
+ "proposal-accepted",
+ "refresh-revealed",
+ "withdraw-group-finished"
+)
+
data class BalanceItem(val available: Amount, val pendingIncoming: Amount)
class MainViewModel(val app: Application) : AndroidViewModel(app) {
@@ -56,6 +62,13 @@ class MainViewModel(val app: Application) : AndroidViewModel(app) {
) {
Log.i(TAG, "Received notification from wallet-core: ${payload.toString(2)}")
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)
+ }
+ }
}
}
@@ -66,7 +79,7 @@ class MainViewModel(val app: Application) : AndroidViewModel(app) {
val withdrawManager = WithdrawManager(walletBackendApi)
val paymentManager = PaymentManager(walletBackendApi, mapper)
val pendingOperationsManager = PendingOperationsManager(walletBackendApi)
- val transactionManager = TransactionManager(walletBackendApi, mapper)
+ val transactionManager: TransactionManager = TransactionManager(walletBackendApi, mapper)
val refundManager = RefundManager(walletBackendApi)
override fun onCleared() {