mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-23 12:09:43 +00:00
Fixes
This commit is contained in:
parent
43fc4032f4
commit
83dd4d9264
1 changed files with 21 additions and 24 deletions
|
@ -22,8 +22,7 @@ abstract class BalanceViewModelBase with Store {
|
||||||
BalanceViewModelBase(
|
BalanceViewModelBase(
|
||||||
{@required this.appStore,
|
{@required this.appStore,
|
||||||
@required this.settingsStore,
|
@required this.settingsStore,
|
||||||
@required this.fiatConvertationStore
|
@required this.fiatConvertationStore}) {
|
||||||
}){
|
|
||||||
isReversing = false;
|
isReversing = false;
|
||||||
|
|
||||||
wallet ??= appStore.wallet;
|
wallet ??= appStore.wallet;
|
||||||
|
@ -34,17 +33,18 @@ abstract class BalanceViewModelBase with Store {
|
||||||
|
|
||||||
if (_wallet is MoneroWallet) {
|
if (_wallet is MoneroWallet) {
|
||||||
balance = _wallet.balance;
|
balance = _wallet.balance;
|
||||||
|
|
||||||
_onMoneroBalanceChangeReaction = reaction((_) => _wallet.balance,
|
|
||||||
(MoneroBalance moneroBalance) => balance = moneroBalance);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_wallet is BitcoinWallet) {
|
if (_wallet is BitcoinWallet) {
|
||||||
balance = _wallet.balance;
|
balance = _wallet.balance;
|
||||||
|
|
||||||
_onBitcoinBalanceChangeReaction = reaction((_) => _wallet.balance,
|
|
||||||
(BitcoinBalance bitcoinBalance) => balance = bitcoinBalance);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_onCurrentWalletChangeReaction =
|
||||||
|
reaction<void>((_) => wallet.balance, (dynamic balance) {
|
||||||
|
if (balance is Balance) {
|
||||||
|
this.balance = balance;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
final AppStore appStore;
|
final AppStore appStore;
|
||||||
|
@ -120,7 +120,7 @@ abstract class BalanceViewModelBase with Store {
|
||||||
final _balance = balance;
|
final _balance = balance;
|
||||||
|
|
||||||
if (_balance is MoneroBalance) {
|
if (_balance is MoneroBalance) {
|
||||||
return WalletBalance(
|
return WalletBalance(
|
||||||
unlockedBalance: _balance.formattedUnlockedBalance,
|
unlockedBalance: _balance.formattedUnlockedBalance,
|
||||||
totalBalance: _balance.formattedFullBalance);
|
totalBalance: _balance.formattedFullBalance);
|
||||||
}
|
}
|
||||||
|
@ -137,32 +137,29 @@ abstract class BalanceViewModelBase with Store {
|
||||||
@computed
|
@computed
|
||||||
CryptoCurrency get currency => appStore.wallet.currency;
|
CryptoCurrency get currency => appStore.wallet.currency;
|
||||||
|
|
||||||
|
ReactionDisposer _onCurrentWalletChangeReaction;
|
||||||
|
ReactionDisposer _reaction;
|
||||||
|
|
||||||
@action
|
@action
|
||||||
void _onWalletChange(WalletBase wallet) {
|
void _onWalletChange(WalletBase wallet) {
|
||||||
this.wallet = wallet;
|
this.wallet = wallet;
|
||||||
|
|
||||||
if (wallet is MoneroWallet) {
|
if (wallet is MoneroWallet) {
|
||||||
balance = wallet.balance;
|
balance = wallet.balance;
|
||||||
|
|
||||||
_onMoneroBalanceChangeReaction?.reaction?.dispose();
|
|
||||||
|
|
||||||
_onMoneroBalanceChangeReaction = reaction((_) => wallet.balance,
|
|
||||||
(MoneroBalance moneroBalance) => balance = moneroBalance);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wallet is BitcoinWallet) {
|
if (wallet is BitcoinWallet) {
|
||||||
balance = wallet.balance;
|
balance = wallet.balance;
|
||||||
|
|
||||||
_onBitcoinBalanceChangeReaction?.reaction?.dispose();
|
|
||||||
|
|
||||||
_onBitcoinBalanceChangeReaction = reaction((_) => wallet.balance,
|
|
||||||
(BitcoinBalance bitcoinBalance) => balance = bitcoinBalance);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
ReactionDisposer _onMoneroBalanceChangeReaction;
|
_onCurrentWalletChangeReaction?.reaction?.dispose();
|
||||||
ReactionDisposer _onBitcoinBalanceChangeReaction;
|
_onCurrentWalletChangeReaction =
|
||||||
ReactionDisposer _reaction;
|
reaction<void>((_) => wallet.balance, (dynamic balance) {
|
||||||
|
if (balance is Balance) {
|
||||||
|
this.balance = balance;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
String _getFiatBalance({double price, String cryptoAmount}) {
|
String _getFiatBalance({double price, String cryptoAmount}) {
|
||||||
if (cryptoAmount == null) {
|
if (cryptoAmount == null) {
|
||||||
|
|
Loading…
Reference in a new issue