This commit is contained in:
M 2020-08-27 19:54:34 +03:00
parent 5eefd6a31b
commit 6aaac93fa8
28 changed files with 364 additions and 143 deletions

View file

@ -50,7 +50,8 @@ ReactionDisposer _onCurrentWalletChangeReaction;
ReactionDisposer _onWalletSyncStatusChangeReaction;
ReactionDisposer _onCurrentFiatCurrencyChangeDisposer;
Future<void> bootstrap({FiatConvertationService fiatConvertationService}) async {
Future<void> bootstrap(
{FiatConvertationService fiatConvertationService}) async {
final authenticationStore = getIt.get<AuthenticationStore>();
final settingsStore = getIt.get<SettingsStore>();
final fiatConvertationStore = getIt.get<FiatConvertationStore>();
@ -72,12 +73,10 @@ Future<void> bootstrap({FiatConvertationService fiatConvertationService}) async
_onCurrentWalletChangeReaction ??=
reaction((_) => getIt.get<AppStore>().wallet, (WalletBase wallet) async {
print('Wallet name ${wallet.name}');
_onWalletSyncStatusChangeReaction?.reaction?.dispose();
_onWalletSyncStatusChangeReaction = when(
_onWalletSyncStatusChangeReaction = reaction(
(_) => wallet.syncStatus is ConnectedSyncStatus,
() async => await wallet.startSync());
(_) async => await wallet.startSync());
await getIt
.get<SharedPreferences>()
@ -87,30 +86,24 @@ Future<void> bootstrap({FiatConvertationService fiatConvertationService}) async
.get<SharedPreferences>()
.setInt('current_wallet_type', serializeToInt(wallet.type));
await wallet.connectToNode(node: null);
final node = settingsStore.getCurrentNode(wallet.type);
final cryptoCurrency = wallet.currency;
final fiatCurrency = settingsStore.fiatCurrency;
await wallet.connectToNode(node: node);
final price = await fiatConvertationService.getPrice(
crypto: cryptoCurrency,
fiat: fiatCurrency
);
crypto: cryptoCurrency, fiat: fiatCurrency);
fiatConvertationStore.setPrice(price);
});
//
_onCurrentFiatCurrencyChangeDisposer ??=
reaction((_) => settingsStore.fiatCurrency,
(FiatCurrency fiatCurrency) async {
_onCurrentFiatCurrencyChangeDisposer ??= reaction(
(_) => settingsStore.fiatCurrency, (FiatCurrency fiatCurrency) async {
final cryptoCurrency = getIt.get<AppStore>().wallet.currency;
final price = await fiatConvertationService.getPrice(
crypto: cryptoCurrency,
fiat: fiatCurrency
);
crypto: cryptoCurrency, fiat: fiatCurrency);
fiatConvertationStore.setPrice(price);
});