diff --git a/src/app/modules/main/activity_center/module.nim b/src/app/modules/main/activity_center/module.nim index d567b33a59..85f5c2f2c8 100644 --- a/src/app/modules/main/activity_center/module.nim +++ b/src/app/modules/main/activity_center/module.nim @@ -75,8 +75,8 @@ proc createMessageItemFromDto(self: Module, message: MessageDto, chatDetails: Ch chatDetails.communityId, # we don't received community id via `activityCenterNotifications` api call message.responseTo, message.`from`, - contactDetails.details.displayName, - contactDetails.details.localNickname, + contactDetails.defaultDisplayName, + contactDetails.optionalName, contactDetails.icon, contactDetails.isCurrentUser, contactDetails.details.added, diff --git a/src/app/modules/main/chat_section/chat_content/messages/module.nim b/src/app/modules/main/chat_section/chat_content/messages/module.nim index 6f34add995..8d1b645376 100644 --- a/src/app/modules/main/chat_section/chat_content/messages/module.nim +++ b/src/app/modules/main/chat_section/chat_content/messages/module.nim @@ -78,7 +78,7 @@ proc createFetchMoreMessagesItem(self: Module): Item = responseToMessageWithId = "", senderId = chatDto.id, senderDisplayName = "", - senderLocalName = "", + senderOptionalName = "", senderIcon = "", amISender = false, senderIsAdded = false, @@ -117,7 +117,7 @@ proc createChatIdentifierItem(self: Module): Item = responseToMessageWithId = "", senderId = chatDto.id, senderDisplayName = chatName, - senderLocalName = "", + senderOptionalName = "", senderIcon = chatIcon, amISender = false, senderIsAdded, @@ -182,8 +182,8 @@ method newMessagesLoaded*(self: Module, messages: seq[MessageDto], reactions: se m.communityId, m.responseTo, m.`from`, - sender.details.displayName, - sender.details.localNickname, + sender.defaultDisplayName, + sender.optionalName, sender.icon, isCurrentUser, sender.details.added, @@ -219,7 +219,7 @@ method newMessagesLoaded*(self: Module, messages: seq[MessageDto], reactions: se let userWhoAddedThisReaction = self.controller.getContactById(r.`from`) let didIReactWithThisEmoji = userWhoAddedThisReaction.id == singletonInstance.userProfile.getPubKey() item.addReaction(emojiIdAsEnum, didIReactWithThisEmoji, userWhoAddedThisReaction.id, - userWhoAddedThisReaction.userNameOrAlias(), r.id) + userWhoAddedThisReaction.userDefaultDisplayName(), r.id) else: error "wrong emoji id found when loading messages", methodName="newMessagesLoaded" @@ -273,8 +273,8 @@ method messageAdded*(self: Module, message: MessageDto) = message.communityId, message.responseTo, message.`from`, - sender.details.displayName, - sender.details.localNickname, + sender.defaultDisplayName, + sender.optionalName, sender.icon, isCurrentUser, sender.details.added, @@ -356,7 +356,7 @@ method toggleReactionFromOthers*(self: Module, messageId: string, emojiId: int, if(item.shouldAddReaction(emojiIdAsEnum, reactionFrom)): let userWhoAddedThisReaction = self.controller.getContactById(reactionFrom) self.view.model().addReaction(messageId, emojiIdAsEnum, didIReactWithThisEmoji = false, - userWhoAddedThisReaction.id, userWhoAddedThisReaction.userNameOrAlias(), reactionId) + userWhoAddedThisReaction.id, userWhoAddedThisReaction.userDefaultDisplayName(), reactionId) else: self.view.model().removeReaction(messageId, emojiIdAsEnum, reactionId, didIRemoveThisReaction = false) else: @@ -413,8 +413,8 @@ method updateContactDetails*(self: Module, contactId: string) = let updatedContact = self.controller.getContactDetails(contactId) for item in self.view.model().modelContactUpdateIterator(contactId): if(item.senderId == contactId): - item.senderDisplayName = updatedContact.details.displayName - item.senderLocalName = updatedContact.details.localNickname + item.senderDisplayName = updatedContact.defaultDisplayName + item.senderOptionalName = updatedContact.optionalName item.senderIcon = updatedContact.icon item.senderIsAdded = updatedContact.details.added item.senderTrustStatus = updatedContact.details.trustStatus diff --git a/src/app/modules/main/chat_section/chat_content/module.nim b/src/app/modules/main/chat_section/chat_content/module.nim index 2d50642682..65e8d939c9 100644 --- a/src/app/modules/main/chat_section/chat_content/module.nim +++ b/src/app/modules/main/chat_section/chat_content/module.nim @@ -79,7 +79,7 @@ method load*(self: Module) = var trustStatus = TrustStatus.Unknown if(chatDto.chatType == ChatType.OneToOne): let contactDto = self.controller.getContactById(self.controller.getMyChatId()) - chatName = contactDto.userNameOrAlias() + chatName = contactDto.userDefaultDisplayName() isContact = contactDto.isContact trustStatus = contactDto.trustStatus if(contactDto.image.thumbnail.len > 0): @@ -167,8 +167,8 @@ proc buildPinnedMessageItem(self: Module, messageId: string, actionInitiatedBy: m.communityId, m.responseTo, m.`from`, - contactDetails.details.displayName, - contactDetails.details.localNickname, + contactDetails.defaultDisplayName, + contactDetails.optionalName, contactDetails.icon, isCurrentUser, contactDetails.details.added, @@ -206,7 +206,7 @@ proc buildPinnedMessageItem(self: Module, messageId: string, actionInitiatedBy: let userWhoAddedThisReaction = self.controller.getContactById(r.`from`) let didIReactWithThisEmoji = userWhoAddedThisReaction.id == singletonInstance.userProfile.getPubKey() item.addReaction(emojiIdAsEnum, didIReactWithThisEmoji, userWhoAddedThisReaction.id, - userWhoAddedThisReaction.userNameOrAlias(), r.id) + userWhoAddedThisReaction.userDefaultDisplayName(), r.id) else: error "wrong emoji id found when loading messages", methodName="buildPinnedMessageItem" @@ -296,7 +296,7 @@ method toggleReactionFromOthers*(self: Module, messageId: string, emojiId: int, if(item.shouldAddReaction(emojiIdAsEnum, reactionFrom)): let userWhoAddedThisReaction = self.controller.getContactById(reactionFrom) self.view.pinnedModel().addReaction(messageId, emojiIdAsEnum, didIReactWithThisEmoji = false, - userWhoAddedThisReaction.id, userWhoAddedThisReaction.userNameOrAlias(), reactionId) + userWhoAddedThisReaction.id, userWhoAddedThisReaction.userDefaultDisplayName(), reactionId) else: self.view.pinnedModel().removeReaction(messageId, emojiIdAsEnum, reactionId, didIRemoveThisReaction = false) else: @@ -320,8 +320,8 @@ method onContactDetailsUpdated*(self: Module, contactId: string) = let updatedContact = self.controller.getContactDetails(contactId) for item in self.view.pinnedModel().modelContactUpdateIterator(contactId): if(item.senderId == contactId): - item.senderDisplayName = updatedContact.details.displayName - item.senderLocalName = updatedContact.details.localNickname + item.senderDisplayName = updatedContact.defaultDisplayName + item.senderOptionalName = updatedContact.optionalName item.senderEnsVerified = updatedContact.details.ensVerified item.senderIcon = updatedContact.icon item.senderTrustStatus = updatedContact.details.trustStatus diff --git a/src/app/modules/main/chat_section/chat_content/users/module.nim b/src/app/modules/main/chat_section/chat_content/users/module.nim index b5e5b931ab..0ae3f55ec8 100644 --- a/src/app/modules/main/chat_section/chat_content/users/module.nim +++ b/src/app/modules/main/chat_section/chat_content/users/module.nim @@ -75,7 +75,7 @@ method onNewMessagesLoaded*(self: Module, messages: seq[MessageDto]) = let status = toOnlineStatus(statusUpdateDto.statusType) self.view.model().addItem(initMemberItem( pubKey = m.`from`, - displayName = contactDetails.displayName, + displayName = contactDetails.defaultDisplayName, ensName = contactDetails.details.name, # is it correct? localNickname = contactDetails.details.localNickname, alias = contactDetails.details.alias, @@ -91,7 +91,7 @@ method contactNicknameChanged*(self: Module, publicKey: string) = let contactDetails = self.controller.getContactDetails(publicKey) self.view.model().setName( publicKey, - contactDetails.displayName, + contactDetails.defaultDisplayName, contactDetails.details.name, contactDetails.details.localNickname ) @@ -105,7 +105,7 @@ method contactUpdated*(self: Module, publicKey: string) = let contactDetails = self.controller.getContactDetails(publicKey) self.view.model().updateItem( pubKey = publicKey, - displayName = contactDetails.displayName, + displayName = contactDetails.defaultDisplayName, ensName = contactDetails.details.name, localNickname = contactDetails.details.localNickname, alias = contactDetails.details.alias, @@ -142,7 +142,7 @@ method addChatMember*(self: Module, member: ChatMember) = self.view.model().addItem(initMemberItem( pubKey = member.id, - displayName = contactDetails.displayName, + displayName = contactDetails.defaultDisplayName, ensName = contactDetails.details.name, localNickname = contactDetails.details.localNickname, alias = contactDetails.details.alias, @@ -191,7 +191,7 @@ method onChatMemberUpdated*(self: Module, publicKey: string, admin: bool, joined let contactDetails = self.controller.getContactDetails(publicKey) self.view.model().updateItem( pubKey = publicKey, - displayName = contactDetails.details.displayName, + displayName = contactDetails.defaultDisplayName, ensName = contactDetails.details.name, localNickname = contactDetails.details.localNickname, alias = contactDetails.details.alias, diff --git a/src/app/modules/main/chat_section/module.nim b/src/app/modules/main/chat_section/module.nim index 171ce8327e..e88a1081c0 100644 --- a/src/app/modules/main/chat_section/module.nim +++ b/src/app/modules/main/chat_section/module.nim @@ -143,7 +143,7 @@ proc buildChatSectionUI( let belongToCommunity = chatDto.communityId != "" if(chatDto.chatType == ChatType.OneToOne): let contactDetails = self.controller.getContactDetails(chatDto.id) - chatName = contactDetails.displayName + chatName = contactDetails.defaultDisplayName chatImage = contactDetails.icon blocked = contactDetails.details.isBlocked() colorHash = self.controller.getColorHash(chatDto.id) @@ -217,7 +217,7 @@ proc createItemFromPublicKey(self: Module, publicKey: string): UserItem = return initUserItem( pubKey = contactDetails.details.id, - displayName = contactDetails.displayName, + displayName = contactDetails.defaultDisplayName, icon = contactDetails.icon, colorId = contactDetails.colorId, onlineStatus = toOnlineStatus(self.controller.getStatusForContactWithId(publicKey).statusType), @@ -682,10 +682,10 @@ method onContactDetailsUpdated*(self: Module, publicKey: string) = self.view.contactRequestsModel().addItem(item) self.updateParentBadgeNotifications() singletonInstance.globalEvents.showNewContactRequestNotification("New Contact Request", - fmt "{contactDetails.displayName} added you as contact", + fmt "{contactDetails.defaultDisplayName} added you as contact", singletonInstance.userProfile.getPubKey()) - let chatName = contactDetails.displayName + let chatName = contactDetails.defaultDisplayName let chatImage = contactDetails.icon let trustStatus = contactDetails.details.trustStatus self.view.chatsModel().updateItemDetails(publicKey, chatName, chatImage, trustStatus) @@ -711,7 +711,7 @@ method onNewMessagesReceived*(self: Module, sectionIdMsgBelongsTo: string, chatI let contactDetails = self.controller.getContactDetails(message.`from`) let renderedMessageText = self.controller.getRenderedText(message.parsedText) let plainText = singletonInstance.utils.plainText(renderedMessageText) - singletonInstance.globalEvents.showMessageNotification(contactDetails.displayName, plainText, sectionIdMsgBelongsTo, + singletonInstance.globalEvents.showMessageNotification(contactDetails.defaultDisplayName, plainText, sectionIdMsgBelongsTo, self.controller.isCommunity(), messageBelongsToActiveSection, chatIdMsgBelongsTo, messageBelongsToActiveChat, message.id, notificationType.int, chatTypeMsgBelongsTo == ChatType.OneToOne, chatTypeMsgBelongsTo == ChatType.PrivateGroupChat) diff --git a/src/app/modules/main/communities/module.nim b/src/app/modules/main/communities/module.nim index 4889bba0ab..705bfdb565 100644 --- a/src/app/modules/main/communities/module.nim +++ b/src/app/modules/main/communities/module.nim @@ -83,7 +83,7 @@ proc createMemberItem(self: Module, memberId, requestId: string): MemberItem = let contactDetails = self.controller.getContactDetails(memberId) result = initMemberItem( pubKey = memberId, - displayName = contactDetails.displayName, + displayName = contactDetails.defaultDisplayName, ensName = contactDetails.details.name, localNickname = contactDetails.details.localNickname, alias = contactDetails.details.alias, diff --git a/src/app/modules/main/module.nim b/src/app/modules/main/module.nim index 0d4814d2fc..1edbb50d51 100644 --- a/src/app/modules/main/module.nim +++ b/src/app/modules/main/module.nim @@ -251,7 +251,7 @@ proc createChannelGroupItem[T](self: Module[T], c: ChannelGroupDto): SectionItem let contactDetails = self.controller.getContactDetails(member.id) result = initMemberItem( pubKey = member.id, - displayName = contactDetails.displayName, + displayName = contactDetails.defaultDisplayName, ensName = contactDetails.details.name, localNickname = contactDetails.details.localNickname, alias = contactDetails.details.alias, @@ -275,7 +275,7 @@ proc createChannelGroupItem[T](self: Module[T], c: ChannelGroupDto): SectionItem let contactDetails = self.controller.getContactDetails(bannedMemberId) result = initMemberItem( pubKey = bannedMemberId, - displayName = contactDetails.displayName, + displayName = contactDetails.defaultDisplayName, ensName = contactDetails.details.name, localNickname = contactDetails.details.localNickname, alias = contactDetails.details.alias, @@ -289,7 +289,7 @@ proc createChannelGroupItem[T](self: Module[T], c: ChannelGroupDto): SectionItem let contactDetails = self.controller.getContactDetails(requestDto.publicKey) result = initMemberItem( pubKey = requestDto.publicKey, - displayName = contactDetails.displayName, + displayName = contactDetails.defaultDisplayName, ensName = contactDetails.details.name, localNickname = contactDetails.details.localNickname, alias = contactDetails.details.alias, @@ -304,7 +304,7 @@ proc createChannelGroupItem[T](self: Module[T], c: ChannelGroupDto): SectionItem let contactDetails = self.controller.getContactDetails(requestDto.publicKey) result = initMemberItem( pubKey = requestDto.publicKey, - displayName = contactDetails.displayName, + displayName = contactDetails.defaultDisplayName, ensName = contactDetails.details.name, localNickname = contactDetails.details.localNickname, alias = contactDetails.details.alias, @@ -820,7 +820,7 @@ method contactUpdated*[T](self: Module[T], publicKey: string) = let contactDetails = self.controller.getContactDetails(publicKey) self.view.activeSection().updateMember( publicKey, - contactDetails.displayName, + contactDetails.defaultDisplayName, contactDetails.details.name, contactDetails.details.localNickname, contactDetails.details.alias, diff --git a/src/app/modules/main/profile_section/contacts/module.nim b/src/app/modules/main/profile_section/contacts/module.nim index dd98373a63..d0dabd8742 100644 --- a/src/app/modules/main/profile_section/contacts/module.nim +++ b/src/app/modules/main/profile_section/contacts/module.nim @@ -46,7 +46,7 @@ proc createItemFromPublicKey(self: Module, publicKey: string): UserItem = return initUserItem( pubKey = contact.id, - displayName = contactDetails.displayName, + displayName = contactDetails.defaultDisplayName, icon = contactDetails.icon, colorId = contactDetails.colorId, onlineStatus = toOnlineStatus(self.controller.getStatusForContactWithId(publicKey).statusType), diff --git a/src/app/modules/shared_models/message_item.nim b/src/app/modules/shared_models/message_item.nim index 384aae9d88..7151d147e1 100644 --- a/src/app/modules/shared_models/message_item.nim +++ b/src/app/modules/shared_models/message_item.nim @@ -37,7 +37,7 @@ type responseToMessageWithId: string senderId: string senderDisplayName: string - senderLocalName: string + senderOptionalName: string amISender: bool senderIsAdded: bool senderIcon: string @@ -71,7 +71,7 @@ proc initItem*( responseToMessageWithId, senderId, senderDisplayName, - senderLocalName, + senderOptionalName, senderIcon: string, amISender: bool, senderIsAdded: bool, @@ -98,7 +98,7 @@ proc initItem*( result.responseToMessageWithId = responseToMessageWithId result.senderId = senderId result.senderDisplayName = senderDisplayName - result.senderLocalName = senderLocalName + result.senderOptionalName = senderOptionalName result.amISender = amISender result.senderIsAdded = senderIsAdded result.senderIcon = senderIcon @@ -132,7 +132,7 @@ proc `$`*(self: Item): string = responseToMessageWithId: {self.responseToMessageWithId}, senderId: {self.senderId}, senderDisplayName: {$self.senderDisplayName}, - senderLocalName: {self.senderLocalName}, + senderOptionalName: {self.senderOptionalName}, amISender: {$self.amISender}, senderIsAdded: {$self.senderIsAdded}, seen: {$self.seen}, @@ -173,11 +173,11 @@ proc senderDisplayName*(self: Item): string {.inline.} = proc `senderDisplayName=`*(self: Item, value: string) {.inline.} = self.senderDisplayName = value -proc senderLocalName*(self: Item): string {.inline.} = - self.senderLocalName +proc senderOptionalName*(self: Item): string {.inline.} = + self.senderOptionalName -proc `senderLocalName=`*(self: Item, value: string) {.inline.} = - self.senderLocalName = value +proc `senderOptionalName=`*(self: Item, value: string) {.inline.} = + self.senderOptionalName = value proc senderIcon*(self: Item): string {.inline.} = self.senderIcon @@ -295,7 +295,7 @@ proc toJsonNode*(self: Item): JsonNode = "responseToMessageWithId": self.responseToMessageWithId, "senderId": self.senderId, "senderDisplayName": self.senderDisplayName, - "senderLocalName": self.senderLocalName, + "senderOptionalName": self.senderOptionalName, "amISender": self.amISender, "senderIsAdded": self.senderIsAdded, "senderIcon": self.senderIcon, diff --git a/src/app/modules/shared_models/message_item_qobject.nim b/src/app/modules/shared_models/message_item_qobject.nim index f9e68db700..013bca6c33 100644 --- a/src/app/modules/shared_models/message_item_qobject.nim +++ b/src/app/modules/shared_models/message_item_qobject.nim @@ -45,9 +45,9 @@ QtObject: QtProperty[string] senderDisplayName: read = senderDisplayName - proc senderLocalName*(self: MessageItem): string {.slot.} = result = ?.self.messageItem.senderLocalName - QtProperty[string] senderLocalName: - read = senderLocalName + proc senderOptionalName*(self: MessageItem): string {.slot.} = result = ?.self.messageItem.senderOptionalName + QtProperty[string] senderOptionalName: + read = senderOptionalName proc senderEnsVerified*(self: MessageItem): bool {.slot.} = result = ?.self.messageItem.senderEnsVerified QtProperty[bool] senderEnsVerified: diff --git a/src/app/modules/shared_models/message_model.nim b/src/app/modules/shared_models/message_model.nim index a6a8701e6a..5100ab4094 100644 --- a/src/app/modules/shared_models/message_model.nim +++ b/src/app/modules/shared_models/message_model.nim @@ -12,7 +12,7 @@ type ResponseToMessageWithId SenderId SenderDisplayName - SenderLocalName + SenderOptionalName SenderIcon AmISender SenderIsAdded @@ -89,7 +89,7 @@ QtObject: ModelRole.ResponseToMessageWithId.int:"responseToMessageWithId", ModelRole.SenderId.int:"senderId", ModelRole.SenderDisplayName.int:"senderDisplayName", - ModelRole.SenderLocalName.int:"senderLocalName", + ModelRole.SenderOptionalName.int:"senderOptionalName", ModelRole.SenderIcon.int:"senderIcon", ModelRole.AmISender.int:"amISender", ModelRole.SenderIsAdded.int:"senderIsAdded", @@ -150,8 +150,8 @@ QtObject: result = newQVariant(item.senderDisplayName) of ModelRole.SenderTrustStatus: result = newQVariant(item.senderTrustStatus.int) - of ModelRole.SenderLocalName: - result = newQVariant(item.senderLocalName) + of ModelRole.SenderOptionalName: + result = newQVariant(item.senderOptionalName) of ModelRole.SenderIcon: result = newQVariant(item.senderIcon) of ModelRole.AmISender: @@ -401,7 +401,7 @@ QtObject: var roles: seq[int] if(self.items[i].senderId == contactId): roles = @[ModelRole.SenderDisplayName.int, - ModelRole.SenderLocalName.int, + ModelRole.SenderOptionalName.int, ModelRole.SenderIcon.int, ModelRole.SenderIsAdded.int, ModelRole.SenderTrustStatus.int, diff --git a/src/app_service/common/message.nim b/src/app_service/common/message.nim index 79d456a811..03a67c3e91 100644 --- a/src/app_service/common/message.nim +++ b/src/app_service/common/message.nim @@ -11,10 +11,10 @@ proc replaceMentionsWithPubKeys*(allKnownContacts: seq[ContactsDto], message: st let nameMentions = findAll(message, namePattern) var updatedMessage = message - # In the following lines we're free to compare to `x.userNameOrAlias()` cause that's actually what we're displaying + # In the following lines we're free to compare to `x.userDefaultDisplayName()` cause that's actually what we're displaying # in the mentions suggestion list. for mention in aliasMentions: - let listOfMatched = allKnownContacts.filter(x => "@" & x.userNameOrAlias().toLowerAscii == mention.toLowerAscii) + let listOfMatched = allKnownContacts.filter(x => "@" & x.userDefaultDisplayName().toLowerAscii == mention.toLowerAscii) if(listOfMatched.len > 0): updatedMessage = updatedMessage.replaceWord(mention, '@' & listOfMatched[0].id) @@ -24,8 +24,8 @@ proc replaceMentionsWithPubKeys*(allKnownContacts: seq[ContactsDto], message: st updatedMessage = updatedMessage.replaceWord(mention, '@' & listOfMatched[0].id) for mention in nameMentions: - let listOfMatched = allKnownContacts.filter(x => x.userNameOrAlias().toLowerAscii == mention.toLowerAscii or - "@" & x.userNameOrAlias().toLowerAscii == mention.toLowerAscii) + let listOfMatched = allKnownContacts.filter(x => x.userDefaultDisplayName().toLowerAscii == mention.toLowerAscii or + "@" & x.userDefaultDisplayName().toLowerAscii == mention.toLowerAscii) if(listOfMatched.len > 0): updatedMessage = updatedMessage.replaceWord(mention, '@' & listOfMatched[0].id) return updatedMessage diff --git a/src/app_service/service/contacts/dto/contact_details.nim b/src/app_service/service/contacts/dto/contact_details.nim index 2b8594d2e6..52aeb6a403 100644 --- a/src/app_service/service/contacts/dto/contact_details.nim +++ b/src/app_service/service/contacts/dto/contact_details.nim @@ -6,7 +6,8 @@ export contacts type ContactDetails* = object - displayName*: string + defaultDisplayName*: string + optionalName*: string icon*: string isCurrentUser*: bool colorId*: int diff --git a/src/app_service/service/contacts/dto/contacts.nim b/src/app_service/service/contacts/dto/contacts.nim index 3b8ecd67e4..29554e7438 100644 --- a/src/app_service/service/contacts/dto/contacts.nim +++ b/src/app_service/service/contacts/dto/contacts.nim @@ -149,16 +149,24 @@ proc toContactsDto*(jsonObj: JsonNode): ContactsDto = discard jsonObj.getProp("IsSyncing", result.isSyncing) discard jsonObj.getProp("Removed", result.removed) -proc userNameOrAlias*(contact: ContactsDto): string = - if(contact.localNickname.len > 0): - result = contact.localNickname - elif(contact.name.len > 0 and contact.ensVerified): +proc userExtractedName(contact: ContactsDto): string = + if(contact.name.len > 0 and contact.ensVerified): result = prettyEnsName(contact.name) elif contact.displayName.len > 0: result = contact.displayName else: result = contact.alias +proc userDefaultDisplayName*(contact: ContactsDto): string = + if(contact.localNickname.len > 0): + result = contact.localNickname + else: + result = userExtractedName(contact) + +proc userOptionalName*(contact: ContactsDto): string = + if(contact.localNickname.len > 0): + result = userExtractedName(contact) + proc isContactRequestReceived*(self: ContactsDto): bool = return self.hasAddedUs diff --git a/src/app_service/service/contacts/service.nim b/src/app_service/service/contacts/service.nim index 2519654ef0..7b86f8a974 100644 --- a/src/app_service/service/contacts/service.nim +++ b/src/app_service/service/contacts/service.nim @@ -351,17 +351,23 @@ QtObject: return self.contactsStatus[publicKey] - proc getContactNameAndImage*(self: Service, publicKey: string): - tuple[name: string, image: string, largeImage: string] = + proc getContactNameAndImageInternal(self: Service, publicKey: string): + tuple[name: string, optionalName: string, image: string, largeImage: string] = ## This proc should be used accross the app in order to have for the same contact ## same image and name displayed everywhere in the app. let contactDto = self.getContactById(publicKey) - result.name = contactDto.userNameOrAlias() + result.name = contactDto.userDefaultDisplayName() + result.optionalName = contactDto.userOptionalName() if(contactDto.image.thumbnail.len > 0): result.image = contactDto.image.thumbnail if(contactDto.image.large.len > 0): result.largeImage = contactDto.image.large + proc getContactNameAndImage*(self: Service, publicKey: string): + tuple[name: string, image: string, largeImage: string] = + let tempRes = self.getContactNameAndImageInternal(publicKey) + return (tempRes.name, tempRes.image, tempRes.largeImage) + proc saveContact(self: Service, contact: ContactsDto) = # we must keep local contacts updated self.contacts[contact.id] = contact @@ -513,8 +519,9 @@ QtObject: proc getContactDetails*(self: Service, pubKey: string): ContactDetails = result = ContactDetails() - let (name, icon, _) = self.getContactNameAndImage(pubKey) - result.displayName = name + let (name, optionalName, icon, _) = self.getContactNameAndImageInternal(pubKey) + result.defaultDisplayName = name + result.optionalName = optionalName result.icon = icon result.colorId = procs_from_visual_identity_service.colorIdOf(pubKey) result.isCurrentUser = pubKey == singletonInstance.userProfile.getPubKey() diff --git a/src/app_service/service/message/service.nim b/src/app_service/service/message/service.nim index 9a535694a9..8179f92084 100644 --- a/src/app_service/service/message/service.nim +++ b/src/app_service/service/message/service.nim @@ -687,7 +687,7 @@ proc renderInline(self: Service, parsedText: ParsedText): string = if isCompressedPubKey(id): id = status_accounts.decompressPk(id).result let contactDto = self.contactService.getContactById(id) - result = fmt("{contactDto.userNameOrAlias()}") + result = fmt("{contactDto.userDefaultDisplayName()}") of PARSED_TEXT_CHILD_TYPE_STATUS_TAG: result = fmt("#{value}") of PARSED_TEXT_CHILD_TYPE_DEL: diff --git a/ui/app/AppLayouts/Chat/popups/PinnedMessagesPopup.qml b/ui/app/AppLayouts/Chat/popups/PinnedMessagesPopup.qml index fa9b402ece..40523f5902 100644 --- a/ui/app/AppLayouts/Chat/popups/PinnedMessagesPopup.qml +++ b/ui/app/AppLayouts/Chat/popups/PinnedMessagesPopup.qml @@ -72,8 +72,8 @@ StatusDialog { responseToMessageWithId: model.responseToMessageWithId senderId: model.senderId senderDisplayName: model.senderDisplayName - senderLocalName: model.senderLocalName - senderEnsName: model.senderEnsVerified ? model.senderDisplayName : "" + senderOptionalName: model.senderOptionalName + senderIsEnsVerified: model.senderEnsVerified senderIcon: model.senderIcon amISender: model.amISender messageText: model.messageText diff --git a/ui/app/AppLayouts/Chat/views/ChatMessagesView.qml b/ui/app/AppLayouts/Chat/views/ChatMessagesView.qml index 25a3ca98df..fd7cc13e41 100644 --- a/ui/app/AppLayouts/Chat/views/ChatMessagesView.qml +++ b/ui/app/AppLayouts/Chat/views/ChatMessagesView.qml @@ -275,8 +275,8 @@ Item { responseToMessageWithId: model.responseToMessageWithId senderId: model.senderId senderDisplayName: model.senderDisplayName - senderLocalName: model.senderLocalName - senderEnsName: model.senderEnsVerified ? model.senderDisplayName : "" + senderOptionalName: model.senderOptionalName + senderIsEnsVerified: model.senderEnsVerified senderIcon: model.senderIcon senderIsAdded: model.senderIsAdded amISender: model.amISender diff --git a/ui/app/mainui/activitycenter/views/ActivityCenterMessageComponentView.qml b/ui/app/mainui/activitycenter/views/ActivityCenterMessageComponentView.qml index 9967ce8273..2cf31db34d 100644 --- a/ui/app/mainui/activitycenter/views/ActivityCenterMessageComponentView.qml +++ b/ui/app/mainui/activitycenter/views/ActivityCenterMessageComponentView.qml @@ -130,7 +130,8 @@ Item { messageText: model.message.messageText responseToMessageWithId: model.message.responseToMessageWithId senderId: model.message.senderId - senderLocalName: model.message.senderLocalName + senderOptionalName: model.message.senderOptionalName + senderIsEnsVerified: model.message.senderEnsVerified senderIcon: model.message.senderIcon amISender: model.message.amISender messageImage: model.message.messageImage diff --git a/ui/imports/shared/views/chat/MessageView.qml b/ui/imports/shared/views/chat/MessageView.qml index e438682603..6fc0828cb7 100644 --- a/ui/imports/shared/views/chat/MessageView.qml +++ b/ui/imports/shared/views/chat/MessageView.qml @@ -39,8 +39,8 @@ Loader { property string responseToMessageWithId: "" property string senderId: "" property string senderDisplayName: "" - property string senderLocalName: "" - property string senderEnsName: "" + property string senderOptionalName: "" + property bool senderIsEnsVerified: false property string senderIcon: "" property bool amISender: false property bool senderIsAdded: false @@ -542,9 +542,9 @@ Loader { amISender: root.amISender sender.id: root.senderId - sender.userName: root.senderDisplayName - sender.localName: root.senderLocalName - sender.ensName: root.senderEnsName + sender.displayName: root.senderDisplayName + sender.secondaryName: root.senderOptionalName + sender.isEnsVerified: root.senderIsEnsVerified sender.isContact: root.senderIsAdded sender.trustIndicator: root.senderTrustStatus sender.profileImage { @@ -575,9 +575,9 @@ Loader { amISender: delegate.replyMessage && delegate.replyMessage.amISender sender.id: delegate.replyMessage ? delegate.replyMessage.senderId : "" sender.isContact: delegate.replyMessage && delegate.replyMessage.senderIsAdded - sender.userName: delegate.replyMessage ? delegate.replyMessage.senderDisplayName: "" - sender.ensName: delegate.replyMessage && delegate.replyMessage.ensVerified ? delegate.replyMessage.senderDisplayName : "" - sender.localName: delegate.replyMessage ? delegate.replyMessage.senderLocalName : "" + sender.displayName: delegate.replyMessage ? delegate.replyMessage.senderDisplayName: "" + sender.isEnsVerified: delegate.replyMessage && delegate.replyMessage.senderEnsVerified + sender.secondaryName: delegate.replyMessage ? delegate.replyMessage.senderOptionalName : "" sender.profileImage { width: 20 height: 20