fix: ensure contact data is refetched when changes where made

Changes in contact data caused via calls to any contact related APIs wouldn't be
reflected in the UI because it doesn't re-fetch the updated state from status-go.

This commit makes the contactsService `fetchContacts` API public so it can be
used on the profile section control to re-fetch contact data when changes to
contacts have been emitted.
This commit is contained in:
Pascal Precht 2021-11-23 14:02:39 +01:00 committed by Richard Ramos
parent f4a33036e6
commit 338c7854b0
2 changed files with 5 additions and 1 deletions

View File

@ -34,18 +34,22 @@ method delete*[T](self: Controller[T]) =
method init*[T](self: Controller[T]) = method init*[T](self: Controller[T]) =
self.events.on("contactAdded") do(e: Args): self.events.on("contactAdded") do(e: Args):
self.contactsService.fetchContacts()
let contacts = self.getContacts() let contacts = self.getContacts()
self.delegate.setContactList(contacts) self.delegate.setContactList(contacts)
self.events.on("contactBlocked") do(e: Args): self.events.on("contactBlocked") do(e: Args):
self.contactsService.fetchContacts()
let contacts = self.getContacts() let contacts = self.getContacts()
self.delegate.setContactList(contacts) self.delegate.setContactList(contacts)
self.events.on("contactUnblocked") do(e: Args): self.events.on("contactUnblocked") do(e: Args):
self.contactsService.fetchContacts()
let contacts = self.getContacts() let contacts = self.getContacts()
self.delegate.setContactList(contacts) self.delegate.setContactList(contacts)
self.events.on("contactRemoved") do(e: Args): self.events.on("contactRemoved") do(e: Args):
self.contactsService.fetchContacts()
let contacts = self.getContacts() let contacts = self.getContacts()
self.delegate.setContactList(contacts) self.delegate.setContactList(contacts)

View File

@ -40,7 +40,7 @@ QtObject:
result.threadpool = threadpool result.threadpool = threadpool
result.contacts = initTable[string, ContactsDto]() result.contacts = initTable[string, ContactsDto]()
proc fetchContacts(self: Service) = proc fetchContacts*(self: Service) =
try: try:
let response = status_contacts.getContacts() let response = status_contacts.getContacts()