This commit is contained in:
fosse 2023-08-10 19:29:51 -04:00
parent 181ca98688
commit 0217c2db8b
4 changed files with 9 additions and 26 deletions

View file

@ -21,16 +21,15 @@ abstract class NanoAccountListBase with Store {
String address; String address;
Future<void> update() async { Future<void> update(String? address) async {
if (_isUpdating) { if (_isUpdating) {
return; return;
} }
try { try {
_isUpdating = true; _isUpdating = true;
// refresh();
print(this.address); final accounts = await getAll(address: address ?? this.address);
final accounts = await getAll();
if (accounts.isNotEmpty) { if (accounts.isNotEmpty) {
this.accounts.clear(); this.accounts.clear();
@ -44,8 +43,8 @@ abstract class NanoAccountListBase with Store {
} }
} }
Future<List<NanoAccount>> getAll() async { Future<List<NanoAccount>> getAll({String? address}) async {
final box = await Hive.openBox<NanoAccount>(address); final box = await Hive.openBox<NanoAccount>(address ?? this.address);
// get all accounts in box: // get all accounts in box:
return box.values.toList(); return box.values.toList();

View file

@ -23,8 +23,6 @@ abstract class NanoWalletAddressesBase extends WalletAddresses with Store {
@observable @observable
NanoAccount? account; NanoAccount? account;
// NanoSubaddressList subaddressList;
NanoAccountList accountList; NanoAccountList accountList;
@override @override
@ -33,26 +31,14 @@ abstract class NanoWalletAddressesBase extends WalletAddresses with Store {
try { try {
box.getAt(0); box.getAt(0);
} catch (e) { } catch (e) {
box.add(NanoAccount(id: 0, label: "Primary Account", balance: "0")); box.add(NanoAccount(id: 0, label: "Primary Account", balance: "0.00"));
} }
await accountList.update(); await accountList.update(walletInfo.address);
print("####################");
print(accountList.accounts);
account = accountList.accounts.first; account = accountList.accounts.first;
address = walletInfo.address; address = walletInfo.address;
await updateAddressesInBox();
} }
@override @override
Future<void> updateAddressesInBox() async { Future<void> updateAddressesInBox() async {}
// try {
// addressesMap.clear();
// addressesMap[address] = '';
// await saveAddressesInBox();
// } catch (e) {
// print(e.toString());
// }
}
} }

View file

@ -17,7 +17,7 @@ class CWNanoAccountList extends NanoAccountList {
@override @override
void update(Object wallet) { void update(Object wallet) {
final nanoWallet = wallet as NanoWallet; final nanoWallet = wallet as NanoWallet;
nanoWallet.walletAddresses.accountList.update(); nanoWallet.walletAddresses.accountList.update(null);
} }
@override @override

View file

@ -20,8 +20,6 @@ class NanoAccountListPage extends StatelessWidget {
return Observer(builder: (_) { return Observer(builder: (_) {
final accounts = accountListViewModel.accounts; final accounts = accountListViewModel.accounts;
print(accounts);
return PickerInnerWrapperWidget( return PickerInnerWrapperWidget(
title: S.of(context).choose_account, title: S.of(context).choose_account,
itemsHeight: (itemHeight * accounts.length) + buttonHeight, itemsHeight: (itemHeight * accounts.length) + buttonHeight,