Skip to content

Commit a0f84b5

Browse files
committed
undo latest solution
1 parent 18c7b00 commit a0f84b5

2 files changed

Lines changed: 10 additions & 27 deletions

File tree

app/lib/screens/wallets/contacts.dart

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -38,27 +38,18 @@ class _ContactsScreenState extends State<ContactsScreen> {
3838
}
3939

4040
_loadFavouriteContacts() async {
41-
final allContacts = await getPkidContacts();
42-
43-
final seen = <String>{};
44-
final filtered = <PkidContact>[];
45-
46-
for (final c in allContacts) {
47-
if (c.type != widget.chainType) continue;
48-
49-
final key = '${c.address}_${c.type}';
50-
if (seen.add(key)) {
51-
filtered.add(c);
52-
}
53-
}
54-
55-
myPkidContacts = filtered;
41+
myPkidContacts = await getPkidContacts();
42+
myPkidContacts =
43+
myPkidContacts.where((c) => c.type == widget.chainType).toList();
5644
setState(() {});
5745
}
5846

5947
_onAddContact(PkidContact contact) async {
60-
myPkidContacts.add(contact);
61-
setState(() {});
48+
final exists = myPkidContacts.any((c) => c.name == contact.name && c.address == contact.address);
49+
if (!exists) {
50+
myPkidContacts.add(contact);
51+
setState(() {});
52+
}
6253
}
6354

6455
_openAddContactOverlay() {

app/lib/widgets/wallets/add_edit_contact.dart

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -127,16 +127,8 @@ class _AddEditContactState extends State<AddEditContact> {
127127
return;
128128
}
129129
if (chainType == widget.chainType) {
130-
final alreadyExists = widget.contacts
131-
.any((c) => c.address == contactAddress && c.type == chainType);
132-
133-
if (!alreadyExists) {
134-
widget.onAddContact!(PkidContact(
135-
name: contactName,
136-
address: contactAddress,
137-
type: chainType,
138-
));
139-
}
130+
widget.onAddContact!(PkidContact(
131+
name: contactName, address: contactAddress, type: chainType));
140132
}
141133
if (!context.mounted) return;
142134
Navigator.pop(context);

0 commit comments

Comments
 (0)