Skip to content
Snippets Groups Projects
Commit ea997595 authored by Vincent Texier's avatar Vincent Texier
Browse files

Fix bug in adding contact that already exists

parent 8bb9735f
No related branches found
No related tags found
No related merge requests found
...@@ -82,7 +82,12 @@ class Account(object): ...@@ -82,7 +82,12 @@ class Account(object):
return (key.pubkey == self.pubkey) return (key.pubkey == self.pubkey)
def add_contact(self, person): def add_contact(self, person):
self.contacts.append(person) same_contact = [contact for contact in self.contacts if person.pubkey == contact.pubkey]
if len(same_contact) == 0:
print("add contact")
self.contacts.append(person)
return True
return False
def add_community(self, server, port): def add_community(self, server, port):
logging.debug("Adding a community") logging.debug("Adding a community")
......
...@@ -31,9 +31,10 @@ class AddContactDialog(QDialog, Ui_AddContactDialog): ...@@ -31,9 +31,10 @@ class AddContactDialog(QDialog, Ui_AddContactDialog):
def accept(self): def accept(self):
name = self.edit_name.text() name = self.edit_name.text()
pubkey = self.edit_pubkey.text() pubkey = self.edit_pubkey.text()
self.account.add_contact(Person(name, pubkey)) result = self.account.add_contact(Person(name, pubkey))
self.main_window.menu_contacts_list.addAction(name) if result:
self.main_window.app.save(self.account) self.main_window.menu_contacts_list.addAction(name)
self.main_window.app.save(self.account)
self.close() self.close()
def name_edited(self, new_name): def name_edited(self, new_name):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment