avoid updating wallet info before finishing opening

remove unused var
This commit is contained in:
sneurlax 2024-01-22 21:24:30 -06:00
parent 11f55fb6d1
commit f52b950650
3 changed files with 12 additions and 0 deletions

View file

@ -55,6 +55,7 @@ class MoneroWallet extends CryptonoteWallet with CwBasedInterface {
@override @override
Future<void> exitCwWallet() async { Future<void> exitCwWallet() async {
walletOpen = false;
(cwWalletBase as MoneroWalletBase?)?.onNewBlock = null; (cwWalletBase as MoneroWalletBase?)?.onNewBlock = null;
(cwWalletBase as MoneroWalletBase?)?.onNewTransaction = null; (cwWalletBase as MoneroWalletBase?)?.onNewTransaction = null;
(cwWalletBase as MoneroWalletBase?)?.syncStatusChanged = null; (cwWalletBase as MoneroWalletBase?)?.syncStatusChanged = null;
@ -63,6 +64,8 @@ class MoneroWallet extends CryptonoteWallet with CwBasedInterface {
@override @override
Future<void> open() async { Future<void> open() async {
walletOpen = false;
String? password; String? password;
try { try {
password = await cwKeysStorage.getWalletPassword(walletName: walletId); password = await cwKeysStorage.getWalletPassword(walletName: walletId);
@ -87,6 +90,8 @@ class MoneroWallet extends CryptonoteWallet with CwBasedInterface {
const Duration(seconds: 193), const Duration(seconds: 193),
(_) async => await cwWalletBase?.save(), (_) async => await cwWalletBase?.save(),
); );
walletOpen = true;
} }
@override @override
@ -152,6 +157,8 @@ class MoneroWallet extends CryptonoteWallet with CwBasedInterface {
@override @override
Future<void> updateTransactions() async { Future<void> updateTransactions() async {
if (!walletOpen) return;
await (cwWalletBase as MoneroWalletBase?)?.updateTransactions(); await (cwWalletBase as MoneroWalletBase?)?.updateTransactions();
final transactions = final transactions =
(cwWalletBase as MoneroWalletBase?)?.transactionHistory?.transactions; (cwWalletBase as MoneroWalletBase?)?.transactionHistory?.transactions;

View file

@ -7,6 +7,8 @@ abstract class CryptonoteWallet<T extends CryptonoteCurrency> extends Wallet<T>
with MnemonicInterface<T> { with MnemonicInterface<T> {
CryptonoteWallet(T currency) : super(currency); CryptonoteWallet(T currency) : super(currency);
bool walletOpen = false;
// ========== Overrides ====================================================== // ========== Overrides ======================================================
@override @override

View file

@ -244,6 +244,8 @@ mixin CwBasedInterface<T extends CryptonoteCurrency> on CryptonoteWallet<T>
@override @override
Future<void> updateBalance() async { Future<void> updateBalance() async {
if (!walletOpen) return;
final total = await totalBalance; final total = await totalBalance;
final available = await availableBalance; final available = await availableBalance;
@ -300,6 +302,7 @@ mixin CwBasedInterface<T extends CryptonoteCurrency> on CryptonoteWallet<T>
@override @override
Future<void> exit() async { Future<void> exit() async {
if (!_hasCalledExit) { if (!_hasCalledExit) {
walletOpen = false;
_hasCalledExit = true; _hasCalledExit = true;
autoSaveTimer?.cancel(); autoSaveTimer?.cancel();
await exitCwWallet(); await exitCwWallet();