[skip ci] fix issues from code review

This commit is contained in:
Godwin Asuquo
2022-12-13 16:19:31 +01:00
parent 59484e5b91
commit f15bc28219
6 changed files with 73 additions and 52 deletions
@@ -15,9 +15,12 @@ part 'wallet_list_view_model.g.dart';
class WalletListViewModel = WalletListViewModelBase with _$WalletListViewModel;
abstract class WalletListViewModelBase with Store {
WalletListViewModelBase(this._walletInfoSource, this._appStore,
this._walletLoadingService)
: wallets = ObservableList<WalletListItem>() {
WalletListViewModelBase(
this._walletInfoSource,
this._appStore,
this._walletLoadingService,
this._authService,
) : wallets = ObservableList<WalletListItem>() {
_updateList();
}
@@ -27,6 +30,7 @@ abstract class WalletListViewModelBase with Store {
final AppStore _appStore;
final Box<WalletInfo> _walletInfoSource;
final WalletLoadingService _walletLoadingService;
final AuthService _authService;
WalletType get currentWalletType => _appStore.wallet!.type;
@@ -47,16 +51,20 @@ abstract class WalletListViewModelBase with Store {
void _updateList() {
wallets.clear();
wallets.addAll(_walletInfoSource.values.map((info) => WalletListItem(
name: info.name,
type: info.type,
key: info.key,
isCurrent: info.name == _appStore.wallet!.name &&
info.type == _appStore.wallet!.type,
isEnabled: availableWalletTypes.contains(info.type))));
wallets.addAll(
_walletInfoSource.values.map(
(info) => WalletListItem(
name: info.name,
type: info.type,
key: info.key,
isCurrent: info.name == _appStore.wallet!.name && info.type == _appStore.wallet!.type,
isEnabled: availableWalletTypes.contains(info.type),
),
),
);
}
bool checkIfAuthRequired(){
return getIt.get<AuthService>().requireAuth();
bool checkIfAuthRequired() {
return _authService.requireAuth();
}
}