diff --git a/lib/di.dart b/lib/di.dart index 15a47f04b..137701416 100644 --- a/lib/di.dart +++ b/lib/di.dart @@ -157,7 +157,7 @@ Future setup( }); getIt.registerFactory( - () => WalletAddressListViewModel(wallet: getIt.get().wallet)); + () => WalletAddressListViewModel(appStore: getIt.get())); getIt.registerFactory(() => BalanceViewModel( appStore: getIt.get(), diff --git a/lib/entities/fs_migration.dart b/lib/entities/fs_migration.dart index 462e30843..54b72c9ce 100644 --- a/lib/entities/fs_migration.dart +++ b/lib/entities/fs_migration.dart @@ -8,6 +8,7 @@ import 'package:cake_wallet/entities/encrypt.dart'; import 'package:cake_wallet/entities/fiat_currency.dart'; import 'package:cake_wallet/entities/ios_legacy_helper.dart' as ios_legacy_helper; +import 'package:cake_wallet/entities/preferences_key.dart'; import 'package:cake_wallet/entities/secret_store_key.dart'; import 'package:cake_wallet/entities/wallet_info.dart'; import 'package:cake_wallet/entities/wallet_type.dart'; @@ -98,7 +99,7 @@ Future ios_migrate_user_defaults() async { //assign the pin lenght final pinLength = await ios_legacy_helper.getInt('pin-length'); - await prefs.setInt('pin-length', pinLength); + await prefs.setInt(PreferencesKey.currentPinLength, pinLength); //default value for display list key? final walletName = await ios_legacy_helper.getString('current_wallet_name'); diff --git a/lib/view_model/wallet_address_list/wallet_address_list_view_model.dart b/lib/view_model/wallet_address_list/wallet_address_list_view_model.dart index 0c8d10502..e8c897bfc 100644 --- a/lib/view_model/wallet_address_list/wallet_address_list_view_model.dart +++ b/lib/view_model/wallet_address_list/wallet_address_list_view_model.dart @@ -1,3 +1,4 @@ +import 'package:cake_wallet/store/app_store.dart'; import 'package:flutter/foundation.dart'; import 'package:mobx/mobx.dart'; import 'package:cake_wallet/bitcoin/bitcoin_wallet.dart'; @@ -54,9 +55,12 @@ class BitcoinURI extends PaymentURI { } abstract class WalletAddressListViewModelBase with Store { - WalletAddressListViewModelBase({@required WalletBase wallet}) { + WalletAddressListViewModelBase( + {@required AppStore appStore}) { hasAccounts = _wallet is MoneroWallet; - _wallet = wallet; + _appStore = appStore; + _wallet = _appStore.wallet; + _onWalletChangeReaction = reaction((_) => _appStore.wallet, (WalletBase wallet) => _wallet = wallet); _init(); } @@ -111,10 +115,15 @@ abstract class WalletAddressListViewModelBase with Store { bool hasAccounts; + @observable WalletBase _wallet; List _baseItems; + AppStore _appStore; + + ReactionDisposer _onWalletChangeReaction; + @computed String get accountLabel { final wallet = _wallet;