mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-11 05:14:46 +00:00
save
This commit is contained in:
parent
181ca98688
commit
0217c2db8b
4 changed files with 9 additions and 26 deletions
|
@ -21,16 +21,15 @@ abstract class NanoAccountListBase with Store {
|
|||
|
||||
String address;
|
||||
|
||||
Future<void> update() async {
|
||||
Future<void> update(String? address) async {
|
||||
if (_isUpdating) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
_isUpdating = true;
|
||||
// refresh();
|
||||
print(this.address);
|
||||
final accounts = await getAll();
|
||||
|
||||
final accounts = await getAll(address: address ?? this.address);
|
||||
|
||||
if (accounts.isNotEmpty) {
|
||||
this.accounts.clear();
|
||||
|
@ -44,8 +43,8 @@ abstract class NanoAccountListBase with Store {
|
|||
}
|
||||
}
|
||||
|
||||
Future<List<NanoAccount>> getAll() async {
|
||||
final box = await Hive.openBox<NanoAccount>(address);
|
||||
Future<List<NanoAccount>> getAll({String? address}) async {
|
||||
final box = await Hive.openBox<NanoAccount>(address ?? this.address);
|
||||
|
||||
// get all accounts in box:
|
||||
return box.values.toList();
|
||||
|
|
|
@ -23,8 +23,6 @@ abstract class NanoWalletAddressesBase extends WalletAddresses with Store {
|
|||
@observable
|
||||
NanoAccount? account;
|
||||
|
||||
// NanoSubaddressList subaddressList;
|
||||
|
||||
NanoAccountList accountList;
|
||||
|
||||
@override
|
||||
|
@ -33,26 +31,14 @@ abstract class NanoWalletAddressesBase extends WalletAddresses with Store {
|
|||
try {
|
||||
box.getAt(0);
|
||||
} 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();
|
||||
print("####################");
|
||||
print(accountList.accounts);
|
||||
await accountList.update(walletInfo.address);
|
||||
account = accountList.accounts.first;
|
||||
address = walletInfo.address;
|
||||
|
||||
await updateAddressesInBox();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> updateAddressesInBox() async {
|
||||
// try {
|
||||
// addressesMap.clear();
|
||||
// addressesMap[address] = '';
|
||||
// await saveAddressesInBox();
|
||||
// } catch (e) {
|
||||
// print(e.toString());
|
||||
// }
|
||||
}
|
||||
Future<void> updateAddressesInBox() async {}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ class CWNanoAccountList extends NanoAccountList {
|
|||
@override
|
||||
void update(Object wallet) {
|
||||
final nanoWallet = wallet as NanoWallet;
|
||||
nanoWallet.walletAddresses.accountList.update();
|
||||
nanoWallet.walletAddresses.accountList.update(null);
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
@ -20,8 +20,6 @@ class NanoAccountListPage extends StatelessWidget {
|
|||
|
||||
return Observer(builder: (_) {
|
||||
final accounts = accountListViewModel.accounts;
|
||||
print(accounts);
|
||||
|
||||
return PickerInnerWrapperWidget(
|
||||
title: S.of(context).choose_account,
|
||||
itemsHeight: (itemHeight * accounts.length) + buttonHeight,
|
||||
|
|
Loading…
Reference in a new issue