mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-24 11:15:58 +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
|
@override
|
||||||
Future<void> exit() async {
|
Future<void> exit() async {
|
||||||
_hasCalledExit = true;
|
_hasCalledExit = true;
|
||||||
|
timer?.cancel();
|
||||||
|
timer = null;
|
||||||
|
stopNetworkAlivePinging();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -767,6 +770,22 @@ class BananoWallet extends CoinServiceAPI
|
||||||
coin,
|
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) {
|
} catch (e, s) {
|
||||||
Logging.instance.log(
|
Logging.instance.log(
|
||||||
"Failed to refresh banano wallet $walletId: '$walletName': $e\n$s",
|
"Failed to refresh banano wallet $walletId: '$walletName': $e\n$s",
|
||||||
|
|
|
@ -310,6 +310,9 @@ class NanoWallet extends CoinServiceAPI
|
||||||
@override
|
@override
|
||||||
Future<void> exit() async {
|
Future<void> exit() async {
|
||||||
_hasCalledExit = true;
|
_hasCalledExit = true;
|
||||||
|
timer?.cancel();
|
||||||
|
timer = null;
|
||||||
|
stopNetworkAlivePinging();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -779,6 +782,22 @@ class NanoWallet extends CoinServiceAPI
|
||||||
coin,
|
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) {
|
} catch (e, s) {
|
||||||
Logging.instance.log(
|
Logging.instance.log(
|
||||||
"Failed to refresh nano wallet $walletId: '$walletName': $e\n$s",
|
"Failed to refresh nano wallet $walletId: '$walletName': $e\n$s",
|
||||||
|
|
Loading…
Reference in a new issue