2020-09-21 11:50:26 +00:00
|
|
|
import 'package:mobx/mobx.dart';
|
2021-05-07 07:36:38 +00:00
|
|
|
import 'package:cake_wallet/core/transaction_history.dart';
|
2020-09-21 11:50:26 +00:00
|
|
|
import 'package:cake_wallet/core/wallet_base.dart';
|
2021-05-07 07:36:38 +00:00
|
|
|
import 'package:cake_wallet/entities/balance.dart';
|
|
|
|
import 'package:cake_wallet/entities/transaction_info.dart';
|
2020-09-21 11:50:26 +00:00
|
|
|
import 'package:cake_wallet/entities/sync_status.dart';
|
|
|
|
|
|
|
|
ReactionDisposer _onWalletSyncStatusChangeReaction;
|
|
|
|
|
2021-05-07 07:36:38 +00:00
|
|
|
void startWalletSyncStatusChangeReaction(
|
|
|
|
WalletBase<Balance, TransactionHistoryBase<TransactionInfo>,
|
|
|
|
TransactionInfo>
|
|
|
|
wallet) {
|
2020-09-21 11:50:26 +00:00
|
|
|
_onWalletSyncStatusChangeReaction?.reaction?.dispose();
|
|
|
|
_onWalletSyncStatusChangeReaction =
|
|
|
|
reaction((_) => wallet.syncStatus, (SyncStatus status) async {
|
2021-05-07 07:36:38 +00:00
|
|
|
if (status is ConnectedSyncStatus) {
|
|
|
|
await wallet.startSync();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|