From db205b40e2ff8df1f0cf8fa5dcde09c6b781e1f2 Mon Sep 17 00:00:00 2001 From: julian Date: Thu, 19 Jan 2023 10:29:00 -0600 Subject: [PATCH] notify ui of tx changes and force refresh on rescan --- lib/services/coins/bitcoin/bitcoin_wallet.dart | 12 ++++++++++++ .../coins/bitcoincash/bitcoincash_wallet.dart | 12 ++++++++++++ lib/services/coins/dogecoin/dogecoin_wallet.dart | 12 ++++++++++++ lib/services/coins/epiccash/epiccash_wallet.dart | 12 ++++++++++++ lib/services/coins/firo/firo_wallet.dart | 12 ++++++++++++ lib/services/coins/litecoin/litecoin_wallet.dart | 12 ++++++++++++ lib/services/coins/monero/monero_wallet.dart | 12 ++++++++++++ lib/services/coins/namecoin/namecoin_wallet.dart | 12 ++++++++++++ lib/services/coins/particl/particl_wallet.dart | 12 ++++++++++++ lib/services/coins/wownero/wownero_wallet.dart | 12 ++++++++++++ 10 files changed, 120 insertions(+) diff --git a/lib/services/coins/bitcoin/bitcoin_wallet.dart b/lib/services/coins/bitcoin/bitcoin_wallet.dart index 02c300572..0b7100190 100644 --- a/lib/services/coins/bitcoin/bitcoin_wallet.dart +++ b/lib/services/coins/bitcoin/bitcoin_wallet.dart @@ -2116,6 +2116,17 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { txnsData.add(data); } await addNewTransactionData(txnsData, walletId); + + // quick hack to notify manager to call notifyListeners if + // transactions changed + if (txnsData.isNotEmpty) { + GlobalEventBus.instance.fire( + UpdatedInBackgroundEvent( + "Transactions updated/added for: $walletId $walletName ", + walletId, + ), + ); + } } int estimateTxFee({required int vSize, required int feeRatePerKB}) { @@ -2788,6 +2799,7 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { ); longMutex = false; + await refresh(); Logging.instance.log("Full rescan complete!", level: LogLevel.Info); GlobalEventBus.instance.fire( WalletSyncStatusChangedEvent( diff --git a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart index 94cc16139..b517c7de5 100644 --- a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart +++ b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart @@ -2194,6 +2194,17 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { } await addNewTransactionData(txns, walletId); + + // quick hack to notify manager to call notifyListeners if + // transactions changed + if (txns.isNotEmpty) { + GlobalEventBus.instance.fire( + UpdatedInBackgroundEvent( + "Transactions updated/added for: $walletId $walletName ", + walletId, + ), + ); + } } int estimateTxFee({required int vSize, required int feeRatePerKB}) { @@ -2857,6 +2868,7 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { ); longMutex = false; + await refresh(); Logging.instance.log("Full rescan complete!", level: LogLevel.Info); GlobalEventBus.instance.fire( WalletSyncStatusChangedEvent( diff --git a/lib/services/coins/dogecoin/dogecoin_wallet.dart b/lib/services/coins/dogecoin/dogecoin_wallet.dart index 01d148c51..1bdc98fbf 100644 --- a/lib/services/coins/dogecoin/dogecoin_wallet.dart +++ b/lib/services/coins/dogecoin/dogecoin_wallet.dart @@ -1936,6 +1936,17 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { } await addNewTransactionData(txns, walletId); + + // quick hack to notify manager to call notifyListeners if + // transactions changed + if (txns.isNotEmpty) { + GlobalEventBus.instance.fire( + UpdatedInBackgroundEvent( + "Transactions updated/added for: $walletId $walletName ", + walletId, + ), + ); + } } int estimateTxFee({required int vSize, required int feeRatePerKB}) { @@ -2484,6 +2495,7 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { ); longMutex = false; + await refresh(); Logging.instance.log("Full rescan complete!", level: LogLevel.Info); GlobalEventBus.instance.fire( WalletSyncStatusChangedEvent( diff --git a/lib/services/coins/epiccash/epiccash_wallet.dart b/lib/services/coins/epiccash/epiccash_wallet.dart index 1480a4e02..7d3c70b93 100644 --- a/lib/services/coins/epiccash/epiccash_wallet.dart +++ b/lib/services/coins/epiccash/epiccash_wallet.dart @@ -947,6 +947,7 @@ class EpicCashWallet extends CoinServiceAPI ); return; } + await refresh(); GlobalEventBus.instance.fire( WalletSyncStatusChangedEvent( WalletSyncStatus.synced, @@ -2114,6 +2115,17 @@ class EpicCashWallet extends CoinServiceAPI await addNewTransactionData(txnsData, walletId); + // quick hack to notify manager to call notifyListeners if + // transactions changed + if (txnsData.isNotEmpty) { + GlobalEventBus.instance.fire( + UpdatedInBackgroundEvent( + "Transactions updated/added for: $walletId $walletName ", + walletId, + ), + ); + } + // midSortedArray // .sort((a, b) => (b["timestamp"] as int) - (a["timestamp"] as int)); // diff --git a/lib/services/coins/firo/firo_wallet.dart b/lib/services/coins/firo/firo_wallet.dart index df777a63c..aac0b5ccd 100644 --- a/lib/services/coins/firo/firo_wallet.dart +++ b/lib/services/coins/firo/firo_wallet.dart @@ -3567,6 +3567,17 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { } await addNewTransactionData(txnsData, walletId); + + // quick hack to notify manager to call notifyListeners if + // transactions changed + if (txnsData.isNotEmpty) { + GlobalEventBus.instance.fire( + UpdatedInBackgroundEvent( + "Transactions updated/added for: $walletId $walletName ", + walletId, + ), + ); + } } Future _refreshUTXOs() async { @@ -3886,6 +3897,7 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { await _recoverWalletFromBIP32SeedPhrase(mnemonic!, maxUnusedAddressGap); longMutex = false; + await refresh(); Logging.instance.log("Full rescan complete!", level: LogLevel.Info); GlobalEventBus.instance.fire( WalletSyncStatusChangedEvent( diff --git a/lib/services/coins/litecoin/litecoin_wallet.dart b/lib/services/coins/litecoin/litecoin_wallet.dart index 1a019eacb..0b68132b3 100644 --- a/lib/services/coins/litecoin/litecoin_wallet.dart +++ b/lib/services/coins/litecoin/litecoin_wallet.dart @@ -2196,6 +2196,17 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { txnsData.add(data); } await addNewTransactionData(txnsData, walletId); + + // quick hack to notify manager to call notifyListeners if + // transactions changed + if (txnsData.isNotEmpty) { + GlobalEventBus.instance.fire( + UpdatedInBackgroundEvent( + "Transactions updated/added for: $walletId $walletName ", + walletId, + ), + ); + } } int estimateTxFee({required int vSize, required int feeRatePerKB}) { @@ -2873,6 +2884,7 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { ); longMutex = false; + await refresh(); Logging.instance.log("Full rescan complete!", level: LogLevel.Info); GlobalEventBus.instance.fire( WalletSyncStatusChangedEvent( diff --git a/lib/services/coins/monero/monero_wallet.dart b/lib/services/coins/monero/monero_wallet.dart index 663e5fe34..242683d87 100644 --- a/lib/services/coins/monero/monero_wallet.dart +++ b/lib/services/coins/monero/monero_wallet.dart @@ -221,6 +221,7 @@ class MoneroWallet extends CoinServiceAPI with WalletCache, WalletDB { var restoreHeight = walletBase?.walletInfo.restoreHeight; highestPercentCached = 0; await walletBase?.rescan(height: restoreHeight); + await refresh(); } @override @@ -908,6 +909,17 @@ class MoneroWallet extends CoinServiceAPI with WalletCache, WalletDB { } await addNewTransactionData(txnsData, walletId); + + // quick hack to notify manager to call notifyListeners if + // transactions changed + if (txnsData.isNotEmpty) { + GlobalEventBus.instance.fire( + UpdatedInBackgroundEvent( + "Transactions updated/added for: $walletId $walletName ", + walletId, + ), + ); + } } Future _pathForWalletDir({ diff --git a/lib/services/coins/namecoin/namecoin_wallet.dart b/lib/services/coins/namecoin/namecoin_wallet.dart index 70d3e85ed..26ee63983 100644 --- a/lib/services/coins/namecoin/namecoin_wallet.dart +++ b/lib/services/coins/namecoin/namecoin_wallet.dart @@ -2182,6 +2182,17 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { txnsData.add(data); } await addNewTransactionData(txnsData, walletId); + + // quick hack to notify manager to call notifyListeners if + // transactions changed + if (txnsData.isNotEmpty) { + GlobalEventBus.instance.fire( + UpdatedInBackgroundEvent( + "Transactions updated/added for: $walletId $walletName ", + walletId, + ), + ); + } } int estimateTxFee({required int vSize, required int feeRatePerKB}) { @@ -2862,6 +2873,7 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { ); longMutex = false; + await refresh(); Logging.instance.log("Full rescan complete!", level: LogLevel.Info); GlobalEventBus.instance.fire( WalletSyncStatusChangedEvent( diff --git a/lib/services/coins/particl/particl_wallet.dart b/lib/services/coins/particl/particl_wallet.dart index a0448630b..5caaea47a 100644 --- a/lib/services/coins/particl/particl_wallet.dart +++ b/lib/services/coins/particl/particl_wallet.dart @@ -2349,6 +2349,17 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { } await addNewTransactionData(txns, walletId); + + // quick hack to notify manager to call notifyListeners if + // transactions changed + if (txns.isNotEmpty) { + GlobalEventBus.instance.fire( + UpdatedInBackgroundEvent( + "Transactions updated/added for: $walletId $walletName ", + walletId, + ), + ); + } } int estimateTxFee({required int vSize, required int feeRatePerKB}) { @@ -2961,6 +2972,7 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { ); longMutex = false; + await refresh(); Logging.instance.log("Full rescan complete!", level: LogLevel.Info); GlobalEventBus.instance.fire( WalletSyncStatusChangedEvent( diff --git a/lib/services/coins/wownero/wownero_wallet.dart b/lib/services/coins/wownero/wownero_wallet.dart index 6c2dfcbb7..d295ac68c 100644 --- a/lib/services/coins/wownero/wownero_wallet.dart +++ b/lib/services/coins/wownero/wownero_wallet.dart @@ -244,6 +244,7 @@ class WowneroWallet extends CoinServiceAPI with WalletCache, WalletDB { var restoreHeight = walletBase?.walletInfo.restoreHeight; highestPercentCached = 0; await walletBase?.rescan(height: restoreHeight); + await refresh(); } @override @@ -977,6 +978,17 @@ class WowneroWallet extends CoinServiceAPI with WalletCache, WalletDB { } await addNewTransactionData(txnsData, walletId); + + // quick hack to notify manager to call notifyListeners if + // transactions changed + if (txnsData.isNotEmpty) { + GlobalEventBus.instance.fire( + UpdatedInBackgroundEvent( + "Transactions updated/added for: $walletId $walletName ", + walletId, + ), + ); + } } Future _pathForWalletDir({