2020-09-21 11:50:26 +00:00
|
|
|
import 'package:cake_wallet/core/wallet_base.dart';
|
|
|
|
import 'package:mobx/mobx.dart';
|
|
|
|
|
|
|
|
part 'rescan_view_model.g.dart';
|
|
|
|
|
|
|
|
class RescanViewModel = RescanViewModelBase with _$RescanViewModel;
|
|
|
|
|
|
|
|
enum RescanWalletState { rescaning, none }
|
|
|
|
|
|
|
|
abstract class RescanViewModelBase with Store {
|
|
|
|
RescanViewModelBase(this._wallet) {
|
|
|
|
state = RescanWalletState.none;
|
2020-11-12 19:03:57 +00:00
|
|
|
isButtonEnabled = false;
|
2020-09-21 11:50:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@observable
|
|
|
|
RescanWalletState state;
|
|
|
|
final WalletBase _wallet;
|
|
|
|
|
2020-11-12 19:03:57 +00:00
|
|
|
@observable
|
|
|
|
bool isButtonEnabled;
|
|
|
|
|
2020-09-21 11:50:26 +00:00
|
|
|
@action
|
|
|
|
Future<void> rescanCurrentWallet({int restoreHeight}) async {
|
|
|
|
state = RescanWalletState.rescaning;
|
|
|
|
await _wallet.rescan(height: restoreHeight);
|
|
|
|
state = RescanWalletState.none;
|
|
|
|
}
|
|
|
|
}
|