@@ -26,7 +26,6 @@ import 'package:cw_wownero/wownero_transaction_creation_exception.dart';
2626import 'package:cw_wownero/wownero_transaction_history.dart' ;
2727import 'package:cw_wownero/wownero_transaction_info.dart' ;
2828import 'package:cw_wownero/wownero_wallet_addresses.dart' ;
29- import 'package:flutter/foundation.dart' ;
3029import 'package:mobx/mobx.dart' ;
3130
3231part 'wownero_wallet.g.dart' ;
@@ -90,6 +89,10 @@ abstract class WowneroWalletBase extends WalletBase<WowneroBalance,
9089 late bool _hasSyncAfterStartup;
9190 Timer ? _autoSaveTimer;
9291
92+ void Function ()? onNewBlock;
93+ void Function ()? onNewTransaction;
94+ void Function ()? syncStatusChanged;
95+
9396 Future <void > init () async {
9497 await walletAddresses.init ();
9598 balance = ObservableMap <CryptoCurrency ?, WowneroBalance >.of (<
@@ -112,8 +115,8 @@ abstract class WowneroWalletBase extends WalletBase<WowneroBalance,
112115 }
113116 }
114117
115- _autoSaveTimer = Timer .periodic (
116- Duration (seconds: _autoSaveInterval), (_) async => await save ());
118+ // _autoSaveTimer = Timer.periodic(
119+ // Duration(seconds: _autoSaveInterval), (_) async => await save());
117120 }
118121
119122 @override
@@ -127,15 +130,18 @@ abstract class WowneroWalletBase extends WalletBase<WowneroBalance,
127130 Future <void > connectToNode ({required Node node}) async {
128131 try {
129132 syncStatus = ConnectingSyncStatus ();
133+ syncStatusChanged? .call ();
130134 await wownero_wallet.setupNode (
131135 address: node.uri.toString (),
132136 login: node.login,
133137 password: node.password,
134138 useSSL: node.isSSL,
135139 isLightWallet: false ); // FIXME: hardcoded value
136140 syncStatus = ConnectedSyncStatus ();
141+ syncStatusChanged? .call ();
137142 } catch (e) {
138143 syncStatus = FailedSyncStatus ();
144+ syncStatusChanged? .call ();
139145 print (e);
140146 }
141147 }
@@ -151,8 +157,10 @@ abstract class WowneroWalletBase extends WalletBase<WowneroBalance,
151157 wownero_wallet.startRefresh ();
152158 _setListeners ();
153159 _listener? .start ();
160+ syncStatusChanged? .call ();
154161 } catch (e) {
155162 syncStatus = FailedSyncStatus ();
163+ syncStatusChanged? .call ();
156164 print (e);
157165 rethrow ;
158166 }
@@ -408,6 +416,7 @@ abstract class WowneroWalletBase extends WalletBase<WowneroBalance,
408416 _askForUpdateBalance ();
409417 walletAddresses.accountList.update ();
410418 syncStatus = SyncedSyncStatus ();
419+ syncStatusChanged? .call ();
411420
412421 if (! _hasSyncAfterStartup) {
413422 _hasSyncAfterStartup = true ;
@@ -419,10 +428,12 @@ abstract class WowneroWalletBase extends WalletBase<WowneroBalance,
419428 }
420429 } else {
421430 syncStatus = SyncingSyncStatus (blocksLeft, ptc, height);
431+ syncStatusChanged? .call ();
422432 }
423433 } catch (e) {
424434 print (e.toString ());
425435 }
436+ onNewBlock? .call ();
426437 }
427438
428439 void _onNewTransaction () async {
@@ -433,5 +444,6 @@ abstract class WowneroWalletBase extends WalletBase<WowneroBalance,
433444 } catch (e) {
434445 print (e.toString ());
435446 }
447+ onNewTransaction? .call ();
436448 }
437449}
0 commit comments