Fixes for update fiat rate after change of current wallet type. Fixes for change amount for btc transactions. Changed displaying of balance for btc wallet. General fixes.

This commit is contained in:
M
2020-12-15 18:29:10 +02:00
parent eede39ee7a
commit 8cb9bd15cd
29 changed files with 340 additions and 276 deletions
+4 -3
View File
@@ -12,12 +12,13 @@ Future<void> startFiatRateUpdate(AppStore appStore, SettingsStore settingsStore,
return;
}
fiatConversionStore.price = await FiatConversionService.fetchPrice(
appStore.wallet.currency, settingsStore.fiatCurrency);
fiatConversionStore.prices[appStore.wallet.currency] =
await FiatConversionService.fetchPrice(
appStore.wallet.currency, settingsStore.fiatCurrency);
_timer = Timer.periodic(
Duration(seconds: 30),
(_) async => fiatConversionStore.price =
(_) async => fiatConversionStore.prices[appStore.wallet.currency] =
await FiatConversionService.fetchPrice(
appStore.wallet.currency, settingsStore.fiatCurrency));
}
+6 -5
View File
@@ -7,12 +7,13 @@ import 'package:cake_wallet/entities/fiat_currency.dart';
ReactionDisposer _onCurrentFiatCurrencyChangeDisposer;
void startCurrentFiatChangeReaction(AppStore appStore, SettingsStore settingsStore, FiatConversionStore fiatConversionStore) {
void startCurrentFiatChangeReaction(AppStore appStore,
SettingsStore settingsStore, FiatConversionStore fiatConversionStore) {
_onCurrentFiatCurrencyChangeDisposer?.reaction?.dispose();
_onCurrentFiatCurrencyChangeDisposer = reaction(
(_) => settingsStore.fiatCurrency, (FiatCurrency fiatCurrency) async {
(_) => settingsStore.fiatCurrency, (FiatCurrency fiatCurrency) async {
final cryptoCurrency = appStore.wallet.currency;
fiatConversionStore.price = await FiatConversionService.fetchPrice(
cryptoCurrency, fiatCurrency);
fiatConversionStore.prices[appStore.wallet.currency] =
await FiatConversionService.fetchPrice(cryptoCurrency, fiatCurrency);
});
}
}
+2 -3
View File
@@ -6,10 +6,9 @@ ReactionDisposer _onCurrentNodeChangeReaction;
void startOnCurrentNodeChangeReaction(AppStore appStore) {
_onCurrentNodeChangeReaction?.reaction?.dispose();
_onCurrentNodeChangeReaction =
reaction((_) => appStore.settingsStore.currentNode, (Node node) async {
appStore.settingsStore.nodes.observe((change) async {
try {
await appStore.wallet.connectToNode(node: node);
await appStore.wallet.connectToNode(node: change.newValue);
} catch (e) {
print(e.toString());
}
+10 -1
View File
@@ -12,6 +12,7 @@ import 'package:cake_wallet/core/wallet_base.dart';
import 'package:cake_wallet/entities/wallet_type.dart';
ReactionDisposer _onCurrentWalletChangeReaction;
ReactionDisposer _onCurrentWalletChangeFiatRateUpdateReaction;
void startCurrentWalletChangeReaction(AppStore appStore,
SettingsStore settingsStore, FiatConversionStore fiatConversionStore) {
@@ -29,8 +30,16 @@ void startCurrentWalletChangeReaction(AppStore appStore,
await getIt.get<SharedPreferences>().setInt(
PreferencesKey.currentWalletType, serializeToInt(wallet.type));
await wallet.connectToNode(node: node);
} catch (e) {
print(e.toString());
}
});
fiatConversionStore.price = await FiatConversionService.fetchPrice(
_onCurrentWalletChangeFiatRateUpdateReaction =
reaction((_) => appStore.wallet, (WalletBase wallet) async {
try {
fiatConversionStore.prices[wallet.currency] = 0;
fiatConversionStore.prices[wallet.currency] = await FiatConversionService.fetchPrice(
wallet.currency, settingsStore.fiatCurrency);
} catch (e) {
print(e.toString());