mirror of
https://github.com/status-im/status-desktop.git
synced 2025-02-21 19:18:53 +00:00
refactor(contacts-service): added local name for a contact
Within this commit local name for a contact is added to `ContactsDto` which will be used across the app. - backend part for changing contact's username is added - new signal under `SIGNAL_CONTACT_UPDATED` is introduced for the contacts service - `saveContact` method of the contacts service updated so it saves contact for a real now - in order to be consistent across the app `userNameOrAlias` method is updated so it includes locally set username for a contact
This commit is contained in:
parent
97fa526c5e
commit
0def67e783
@ -79,6 +79,18 @@ method init*[T](self: Controller[T]) =
|
||||
var args = ContactNicknameUpdatedArgs(e)
|
||||
self.delegate.contactNicknameChanged(args.contactId, args.nickname)
|
||||
|
||||
self.events.on(SIGNAL_CONTACT_UPDATED) do(e: Args):
|
||||
# I left this as part it was.
|
||||
let contacts = self.getContacts()
|
||||
self.delegate.setContactList(contacts)
|
||||
|
||||
# Since we have the exact contact which has been updated, then we need to improve the way of updating the view
|
||||
# and instead setting the whole list for every change we should update only the appropriate item in the view.
|
||||
# Example:
|
||||
# let args = ContactUpdatedArgs(e)
|
||||
# let contactDto = self.contactsService.getContactById(args.id)
|
||||
# self.delegate.onContactUpdated(contactDto)
|
||||
|
||||
method getContacts*[T](self: Controller[T]): seq[ContactsDto] =
|
||||
return self.contactsService.getContacts()
|
||||
|
||||
|
@ -36,7 +36,7 @@ method blockContact*(self: AccessInterface, publicKey: string): void {.base.} =
|
||||
method removeContact*(self: AccessInterface, publicKey: string): void {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method changeContactNickname*(self: AccessInterface, publicKey: string, nicknameToSet: string): void {.base.} =
|
||||
method changeContactNickname*(self: AccessInterface, publicKey: string, nickname: string) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method lookupContact*(self: AccessInterface, value: string): void {.base.} =
|
||||
|
@ -95,8 +95,8 @@ method blockContact*[T](self: Module[T], publicKey: string) =
|
||||
method removeContact*[T](self: Module[T], publicKey: string) =
|
||||
self.controller.removeContact(publicKey)
|
||||
|
||||
method changeContactNickname*[T](self: Module[T], publicKey: string, nicknameToSet: string): void =
|
||||
self.controller.changeContactNickname(publicKey, nicknameToSet)
|
||||
method changeContactNickname*[T](self: Module[T], publicKey: string, nickname: string) =
|
||||
self.controller.changeContactNickname(publicKey, nickname)
|
||||
|
||||
method lookupContact*[T](self: Module[T], value: string) =
|
||||
self.controller.lookupContact(value)
|
||||
|
@ -26,6 +26,9 @@ type
|
||||
ContactAddedArgs* = ref object of Args
|
||||
contact*: ContactsDto
|
||||
|
||||
ContactUpdatedArgs* = ref object of Args
|
||||
id*: string
|
||||
|
||||
# Signals which may be emitted by this service:
|
||||
const SIGNAL_CONTACT_LOOKED_UP* = "SIGNAL_CONTACT_LOOKED_UP"
|
||||
# Remove new when old code is removed
|
||||
|
Loading…
x
Reference in New Issue
Block a user