mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-24 04:29:28 +00:00
fix contact bug
This commit is contained in:
parent
c5af031354
commit
ad3ff94bcc
2 changed files with 14 additions and 11 deletions
|
@ -238,6 +238,7 @@ abstract class NanoWalletBase
|
||||||
|
|
||||||
_isTransactionUpdating = true;
|
_isTransactionUpdating = true;
|
||||||
final transactions = await fetchTransactions();
|
final transactions = await fetchTransactions();
|
||||||
|
transactionHistory.clear();
|
||||||
transactionHistory.addMany(transactions);
|
transactionHistory.addMany(transactions);
|
||||||
await transactionHistory.save();
|
await transactionHistory.save();
|
||||||
_isTransactionUpdating = false;
|
_isTransactionUpdating = false;
|
||||||
|
|
|
@ -13,25 +13,29 @@ import 'package:cw_core/crypto_currency.dart';
|
||||||
|
|
||||||
part 'contact_list_view_model.g.dart';
|
part 'contact_list_view_model.g.dart';
|
||||||
|
|
||||||
class ContactListViewModel = ContactListViewModelBase
|
class ContactListViewModel = ContactListViewModelBase with _$ContactListViewModel;
|
||||||
with _$ContactListViewModel;
|
|
||||||
|
|
||||||
abstract class ContactListViewModelBase with Store {
|
abstract class ContactListViewModelBase with Store {
|
||||||
ContactListViewModelBase(this.contactSource, this.walletInfoSource,
|
ContactListViewModelBase(
|
||||||
this._currency, this.settingsStore)
|
this.contactSource, this.walletInfoSource, this._currency, this.settingsStore)
|
||||||
: contacts = ObservableList<ContactRecord>(),
|
: contacts = ObservableList<ContactRecord>(),
|
||||||
walletContacts = [] {
|
walletContacts = [] {
|
||||||
walletInfoSource.values.forEach((info) {
|
walletInfoSource.values.forEach((info) {
|
||||||
if (info.addresses?.isNotEmpty ?? false) {
|
if (info.addresses?.isNotEmpty ?? false) {
|
||||||
info.addresses?.forEach((address, label) {
|
info.addresses?.forEach((address, label) {
|
||||||
final name = label.isNotEmpty ? info.name + ' ($label)' : info.name;
|
final name = label.isNotEmpty ? info.name + ' ($label)' : info.name;
|
||||||
|
|
||||||
walletContacts.add(WalletContact(
|
walletContacts.add(WalletContact(
|
||||||
address,
|
address,
|
||||||
name,
|
name,
|
||||||
walletTypeToCryptoCurrency(info.type),
|
walletTypeToCryptoCurrency(info.type),
|
||||||
));
|
));
|
||||||
});
|
});
|
||||||
|
} else if (info.address != null) {
|
||||||
|
walletContacts.add(WalletContact(
|
||||||
|
info.address,
|
||||||
|
info.name,
|
||||||
|
walletTypeToCryptoCurrency(info.type),
|
||||||
|
));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -57,14 +61,12 @@ abstract class ContactListViewModelBase with Store {
|
||||||
Future<void> delete(ContactRecord contact) async => contact.original.delete();
|
Future<void> delete(ContactRecord contact) async => contact.original.delete();
|
||||||
|
|
||||||
@computed
|
@computed
|
||||||
List<ContactRecord> get contactsToShow => contacts
|
List<ContactRecord> get contactsToShow =>
|
||||||
.where((element) => _isValidForCurrency(element))
|
contacts.where((element) => _isValidForCurrency(element)).toList();
|
||||||
.toList();
|
|
||||||
|
|
||||||
@computed
|
@computed
|
||||||
List<WalletContact> get walletContactsToShow => walletContacts
|
List<WalletContact> get walletContactsToShow =>
|
||||||
.where((element) => _isValidForCurrency(element))
|
walletContacts.where((element) => _isValidForCurrency(element)).toList();
|
||||||
.toList();
|
|
||||||
|
|
||||||
bool _isValidForCurrency(ContactBase element) {
|
bool _isValidForCurrency(ContactBase element) {
|
||||||
return _currency == null || element.type == _currency || element.type.title == _currency!.tag;
|
return _currency == null || element.type == _currency || element.type.title == _currency!.tag;
|
||||||
|
|
Loading…
Reference in a new issue