mirror of
https://github.com/status-im/status-desktop.git
synced 2025-02-27 22:11:10 +00:00
fix(user-list): 1-1 mentions not updating nickname + rearrange events
Fixes #5462
This commit is contained in:
parent
d87e03e969
commit
24a662676e
@ -21,6 +21,9 @@ type
|
|||||||
communityService: community_service.Service
|
communityService: community_service.Service
|
||||||
messageService: message_service.Service
|
messageService: message_service.Service
|
||||||
|
|
||||||
|
# Forward declaration
|
||||||
|
proc getChat*(self: Controller): ChatDto
|
||||||
|
|
||||||
proc newController*(
|
proc newController*(
|
||||||
delegate: io_interface.AccessInterface, events: EventEmitter, sectionId: string, chatId: string,
|
delegate: io_interface.AccessInterface, events: EventEmitter, sectionId: string, chatId: string,
|
||||||
belongsToCommunity: bool, isUsersListAvailable: bool, contactService: contact_service.Service,
|
belongsToCommunity: bool, isUsersListAvailable: bool, contactService: contact_service.Service,
|
||||||
@ -58,31 +61,40 @@ proc handleCommunityOnlyConnections(self: Controller) =
|
|||||||
self.delegate.onChatMembersAdded(membersPubKeys)
|
self.delegate.onChatMembersAdded(membersPubKeys)
|
||||||
|
|
||||||
proc init*(self: Controller) =
|
proc init*(self: Controller) =
|
||||||
if(self.isUsersListAvailable):
|
# Events that are needed for all chats because of mentions
|
||||||
|
self.events.on(SIGNAL_CONTACT_NICKNAME_CHANGED) do(e: Args):
|
||||||
|
let args = ContactArgs(e)
|
||||||
|
self.delegate.contactNicknameChanged(args.contactId)
|
||||||
|
|
||||||
|
self.events.on(SIGNAL_CONTACT_UPDATED) do(e: Args):
|
||||||
|
let args = ContactArgs(e)
|
||||||
|
self.delegate.contactUpdated(args.contactId)
|
||||||
|
|
||||||
|
self.events.on(SIGNAL_LOGGEDIN_USER_IMAGE_CHANGED) do(e: Args):
|
||||||
|
self.delegate.loggedInUserImageChanged()
|
||||||
|
|
||||||
|
let chat = self.getChat()
|
||||||
|
|
||||||
|
# Events only for public chats
|
||||||
|
if chat.isPublicChat():
|
||||||
self.events.on(SIGNAL_MESSAGES_LOADED) do(e:Args):
|
self.events.on(SIGNAL_MESSAGES_LOADED) do(e:Args):
|
||||||
let args = MessagesLoadedArgs(e)
|
let args = MessagesLoadedArgs(e)
|
||||||
if(self.chatId != args.chatId):
|
if(self.chatId != args.chatId):
|
||||||
return
|
return
|
||||||
self.delegate.newMessagesLoaded(args.messages)
|
self.delegate.onNewMessagesLoaded(args.messages)
|
||||||
|
|
||||||
self.events.on(SIGNAL_NEW_MESSAGE_RECEIVED) do(e:Args):
|
self.events.on(SIGNAL_NEW_MESSAGE_RECEIVED) do(e:Args):
|
||||||
let args = MessagesArgs(e)
|
let args = MessagesArgs(e)
|
||||||
if(self.chatId != args.chatId):
|
if(self.chatId != args.chatId):
|
||||||
return
|
return
|
||||||
self.delegate.newMessagesLoaded(args.messages)
|
self.delegate.onNewMessagesLoaded(args.messages)
|
||||||
|
|
||||||
self.events.on(SIGNAL_CONTACT_NICKNAME_CHANGED) do(e: Args):
|
|
||||||
let args = ContactArgs(e)
|
|
||||||
self.delegate.contactNicknameChanged(args.contactId)
|
|
||||||
|
|
||||||
|
# Events only for the user list, so not needed in public and one to one chats
|
||||||
|
if(self.isUsersListAvailable):
|
||||||
self.events.on(SIGNAL_CONTACTS_STATUS_UPDATED) do(e: Args):
|
self.events.on(SIGNAL_CONTACTS_STATUS_UPDATED) do(e: Args):
|
||||||
let args = ContactsStatusUpdatedArgs(e)
|
let args = ContactsStatusUpdatedArgs(e)
|
||||||
self.delegate.contactsStatusUpdated(args.statusUpdates)
|
self.delegate.contactsStatusUpdated(args.statusUpdates)
|
||||||
|
|
||||||
self.events.on(SIGNAL_CONTACT_UPDATED) do(e: Args):
|
|
||||||
let args = ContactArgs(e)
|
|
||||||
self.delegate.contactUpdated(args.contactId)
|
|
||||||
|
|
||||||
self.events.on(SIGNAL_CONTACT_ADDED) do(e: Args):
|
self.events.on(SIGNAL_CONTACT_ADDED) do(e: Args):
|
||||||
let args = ContactArgs(e)
|
let args = ContactArgs(e)
|
||||||
self.delegate.contactUpdated(args.contactId)
|
self.delegate.contactUpdated(args.contactId)
|
||||||
@ -95,9 +107,6 @@ proc init*(self: Controller) =
|
|||||||
let args = ContactArgs(e)
|
let args = ContactArgs(e)
|
||||||
self.delegate.contactUpdated(args.contactId)
|
self.delegate.contactUpdated(args.contactId)
|
||||||
|
|
||||||
self.events.on(SIGNAL_LOGGEDIN_USER_IMAGE_CHANGED) do(e: Args):
|
|
||||||
self.delegate.loggedInUserImageChanged()
|
|
||||||
|
|
||||||
self.events.on(SIGNAL_CHAT_MEMBERS_ADDED) do(e: Args):
|
self.events.on(SIGNAL_CHAT_MEMBERS_ADDED) do(e: Args):
|
||||||
let args = ChatMembersAddedArgs(e)
|
let args = ChatMembersAddedArgs(e)
|
||||||
if (args.chatId == self.chatId):
|
if (args.chatId == self.chatId):
|
||||||
@ -119,6 +128,7 @@ proc init*(self: Controller) =
|
|||||||
if (args.chatId == self.chatId):
|
if (args.chatId == self.chatId):
|
||||||
self.delegate.onChatMemberUpdated(args.id, args.admin, args.joined)
|
self.delegate.onChatMemberUpdated(args.id, args.admin, args.joined)
|
||||||
|
|
||||||
|
# Events only for community channel
|
||||||
if (self.belongsToCommunity):
|
if (self.belongsToCommunity):
|
||||||
self.handleCommunityOnlyConnections()
|
self.handleCommunityOnlyConnections()
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ method isLoaded*(self: AccessInterface): bool {.base.} =
|
|||||||
method getModuleAsVariant*(self: AccessInterface): QVariant {.base.} =
|
method getModuleAsVariant*(self: AccessInterface): QVariant {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
method newMessagesLoaded*(self: AccessInterface, messages: seq[MessageDto]) {.base.} =
|
method onNewMessagesLoaded*(self: AccessInterface, messages: seq[MessageDto]) {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
method contactNicknameChanged*(self: AccessInterface, publicKey: string) {.base.} =
|
method contactNicknameChanged*(self: AccessInterface, publicKey: string) {.base.} =
|
||||||
|
@ -62,11 +62,7 @@ method viewDidLoad*(self: Module) =
|
|||||||
method getModuleAsVariant*(self: Module): QVariant =
|
method getModuleAsVariant*(self: Module): QVariant =
|
||||||
return self.viewVariant
|
return self.viewVariant
|
||||||
|
|
||||||
method newMessagesLoaded*(self: Module, messages: seq[MessageDto]) =
|
method onNewMessagesLoaded*(self: Module, messages: seq[MessageDto]) =
|
||||||
let chat = self.controller.getChat()
|
|
||||||
if not chat.isPublicChat():
|
|
||||||
return
|
|
||||||
|
|
||||||
for m in messages:
|
for m in messages:
|
||||||
if(self.view.model().isContactWithIdAdded(m.`from`)):
|
if(self.view.model().isContactWithIdAdded(m.`from`)):
|
||||||
continue
|
continue
|
||||||
|
@ -115,10 +115,9 @@ proc buildChatUI(self: Module, events: EventEmitter,
|
|||||||
var chatImage = ""
|
var chatImage = ""
|
||||||
var colorHash: ColorHashDto = @[]
|
var colorHash: ColorHashDto = @[]
|
||||||
var colorId: int = 0
|
var colorId: int = 0
|
||||||
var isUsersListAvailable = true
|
let isUsersListAvailable = (c.chatType != ChatType.OneToOne and c.chatType != ChatType.Public)
|
||||||
var blocked = false
|
var blocked = false
|
||||||
if(c.chatType == ChatType.OneToOne):
|
if(c.chatType == ChatType.OneToOne):
|
||||||
isUsersListAvailable = false
|
|
||||||
let contactDetails = self.controller.getContactDetails(c.id)
|
let contactDetails = self.controller.getContactDetails(c.id)
|
||||||
chatName = contactDetails.displayName
|
chatName = contactDetails.displayName
|
||||||
chatImage = contactDetails.icon
|
chatImage = contactDetails.icon
|
||||||
|
@ -259,3 +259,6 @@ proc toChatDto*(jsonObj: JsonNode, communityId: string): ChatDto =
|
|||||||
|
|
||||||
proc isPublicChat*(chatDto: ChatDto): bool =
|
proc isPublicChat*(chatDto: ChatDto): bool =
|
||||||
return chatDto.chatType == ChatType.Public
|
return chatDto.chatType == ChatType.Public
|
||||||
|
|
||||||
|
proc isOneToOneChat*(chatDto: ChatDto): bool =
|
||||||
|
return chatDto.chatType == ChatType.OneToOne
|
||||||
|
Loading…
x
Reference in New Issue
Block a user