mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-09 12:19:24 +00:00
fix: add (ba)nano periodic refreshes
This commit is contained in:
parent
72bbf81c4c
commit
0af9af1ad2
2 changed files with 38 additions and 0 deletions
|
@ -304,6 +304,9 @@ class BananoWallet extends CoinServiceAPI
|
|||
@override
|
||||
Future<void> exit() async {
|
||||
_hasCalledExit = true;
|
||||
timer?.cancel();
|
||||
timer = null;
|
||||
stopNetworkAlivePinging();
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -767,6 +770,22 @@ class BananoWallet extends CoinServiceAPI
|
|||
coin,
|
||||
),
|
||||
);
|
||||
|
||||
if (shouldAutoSync) {
|
||||
timer ??= Timer.periodic(const Duration(seconds: 30), (timer) async {
|
||||
Logging.instance.log(
|
||||
"Periodic refresh check for $walletId $walletName in object instance: $hashCode",
|
||||
level: LogLevel.Info);
|
||||
|
||||
await refresh();
|
||||
GlobalEventBus.instance.fire(
|
||||
UpdatedInBackgroundEvent(
|
||||
"New data found in $walletId $walletName in background!",
|
||||
walletId,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
} catch (e, s) {
|
||||
Logging.instance.log(
|
||||
"Failed to refresh banano wallet $walletId: '$walletName': $e\n$s",
|
||||
|
|
|
@ -310,6 +310,9 @@ class NanoWallet extends CoinServiceAPI
|
|||
@override
|
||||
Future<void> exit() async {
|
||||
_hasCalledExit = true;
|
||||
timer?.cancel();
|
||||
timer = null;
|
||||
stopNetworkAlivePinging();
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -779,6 +782,22 @@ class NanoWallet extends CoinServiceAPI
|
|||
coin,
|
||||
),
|
||||
);
|
||||
|
||||
if (shouldAutoSync) {
|
||||
timer ??= Timer.periodic(const Duration(seconds: 30), (timer) async {
|
||||
Logging.instance.log(
|
||||
"Periodic refresh check for $walletId $walletName in object instance: $hashCode",
|
||||
level: LogLevel.Info);
|
||||
|
||||
await refresh();
|
||||
GlobalEventBus.instance.fire(
|
||||
UpdatedInBackgroundEvent(
|
||||
"New data found in $walletId $walletName in background!",
|
||||
walletId,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
} catch (e, s) {
|
||||
Logging.instance.log(
|
||||
"Failed to refresh nano wallet $walletId: '$walletName': $e\n$s",
|
||||
|
|
Loading…
Reference in a new issue