File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 () {
Original file line number Diff line number Diff 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);
You can’t perform that action at this time.
0 commit comments