fix: make changing local nicknames of contacts work again
This fixes #4173 again. The problem is that changing the local nickname of a contact now uses new APIs in Status Desktop which emit new events that older code isn't aware off. Namely, the event handling in the chat section doesn't get informed anymore that the contact has changed, so it won't update the view accordingly. This commit fixes it by subscribing to that newly introduced event and then updating the view with the payload data. Notice that this is a quick fix and will most likely be obsolete, once the chat section has moved to the new architecture as well. Fixes #4173
This commit is contained in:
parent
6d0d00a50a
commit
cdd79a87e7
|
@ -5,6 +5,10 @@ import # status-desktop libs
|
|||
status/chat/chat as status_chat,
|
||||
./views/communities,
|
||||
./views/messages
|
||||
from ../../app_service/service/contacts/service import ContactArgs
|
||||
from ../../app_service/service/contacts/service import ContactNicknameUpdatedArgs
|
||||
import status/types/profile
|
||||
import status/contacts
|
||||
import ../../app_service/tasks/[qt, threadpool]
|
||||
import ../../app_service/tasks/marathon/mailserver/worker
|
||||
|
||||
|
@ -29,6 +33,19 @@ proc handleChatEvents(self: ChatController) =
|
|||
let notifications = ActivityCenterNotificationsArgs(e).activityCenterNotifications
|
||||
self.view.pushActivityCenterNotifications(notifications)
|
||||
|
||||
# This is a new event emitted and introduced by app_service when
|
||||
# the local nickname of a contact was changed. `contactUpdate` is
|
||||
# no longer emitted in such cases, so we need to make sure to also update
|
||||
# the view when this new event is emitted.
|
||||
self.status.events.on("new-contactNicknameChanged") do(e: Args):
|
||||
var evArgs = ContactNicknameUpdatedArgs(e)
|
||||
let contact = Profile(
|
||||
id: evArgs.contactId,
|
||||
localNickname: evArgs.nickname
|
||||
)
|
||||
self.view.updateUsernames(@[contact])
|
||||
self.view.updateChannelForContacts(@[contact])
|
||||
|
||||
self.status.events.on("contactUpdate") do(e: Args):
|
||||
var evArgs = ContactUpdateArgs(e)
|
||||
self.view.updateUsernames(evArgs.contacts)
|
||||
|
|
|
@ -442,7 +442,8 @@ QtObject:
|
|||
for m in self.messages.mitems:
|
||||
if m.fromAuthor == c.id:
|
||||
m.userName = userNameOrAlias(c)
|
||||
m.alias = c.alias
|
||||
if c.alias != "":
|
||||
m.alias = c.alias
|
||||
m.localName = c.localNickname
|
||||
self.userList.updateUsernames(c.id, m.username, m.alias, m.localname)
|
||||
|
||||
|
|
|
@ -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, accountKeyUID: string, publicKey: string, nicknameToSet: string): void {.base.} =
|
||||
method changeContactNickname*(self: AccessInterface, publicKey: string, nicknameToSet: string): void {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method lookupContact*(self: AccessInterface, value: string): void {.base.} =
|
||||
|
|
|
@ -140,7 +140,7 @@ QtObject:
|
|||
# There are much better ways of notifying qml about this change than sending this signal.
|
||||
# It also may has an impact to the app performances since it's handled on multiple places on the qml side.
|
||||
# Would be good to get rid of it durign refactor phase.
|
||||
proc contactChanged*(self: ContactList, pubkey: string) {.signal.}
|
||||
proc contactChanged*(self: ContactList, pubkey: string, localNickname: string) {.signal.}
|
||||
|
||||
proc updateContact*(self: ContactList, contact: ContactsDto) =
|
||||
var found = false
|
||||
|
@ -158,7 +158,7 @@ QtObject:
|
|||
self.addContactToList(contact)
|
||||
else:
|
||||
self.dataChanged(topLeft, bottomRight, @[ContactRoles.Name.int])
|
||||
self.contactChanged(contact.id)
|
||||
self.contactChanged(contact.id, contact.localNickname)
|
||||
|
||||
proc setNewData*(self: ContactList, contactList: seq[ContactsDto]) =
|
||||
self.beginResetModel()
|
||||
|
@ -176,5 +176,5 @@ QtObject:
|
|||
self.dataChanged(index, index, @[ContactRoles.LocalNickname.int])
|
||||
|
||||
# Wrote about it where this signal is defined, it's emitted from here just because of the qml part.
|
||||
self.contactChanged(self.contacts[i].id)
|
||||
self.contactChanged(self.contacts[i].id, nickname)
|
||||
return
|
||||
|
|
|
@ -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], accountKeyUID: string, publicKey: string, nicknameToSet: string): void =
|
||||
self.controller.changeContactNickname(accountKeyUID, publicKey, nicknameToSet)
|
||||
method changeContactNickname*[T](self: Module[T], publicKey: string, nicknameToSet: string): void =
|
||||
self.controller.changeContactNickname(publicKey, nicknameToSet)
|
||||
|
||||
method lookupContact*[T](self: Module[T], value: string) =
|
||||
self.controller.lookupContact(value)
|
||||
|
|
|
@ -1,44 +0,0 @@
|
|||
import ./dto/contacts as contacts_dto
|
||||
import status/statusgo_backend_new/accounts as status_accounts
|
||||
|
||||
export contacts_dto
|
||||
|
||||
type
|
||||
ServiceInterface* {.pure inheritable.} = ref object of RootObj
|
||||
## Abstract class for this service access.
|
||||
|
||||
method delete*(self: ServiceInterface) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method init*(self: ServiceInterface) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method getContact*(self: ServiceInterface, id: string): contacts_dto.ContactsDto {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method getContacts*(self: ServiceInterface): seq[contacts_dto.ContactsDto] {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method getOrCreateContact*(self: ServiceInterface, id: string): contacts_dto.ContactsDto {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method saveContact*(self: ServiceInterface, contact: contacts_dto.ContactsDto) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method addContact*(self: ServiceInterface, publicKey: string) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method rejectContactRequest*(self: ServiceInterface, publicKey: string) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method changeContactNickname*(self: ServiceInterface, accountKeyUID: string, publicKey: string, nicknameToSet: string) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method unblockContact*(self: ServiceInterface, publicKey: string) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method blockContact*(self: ServiceInterface, publicKey: string) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method removeContact*(self: ServiceInterface, publicKey: string) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
Loading…
Reference in New Issue