fix: fix blurry chat identifier and expose large image in contact proc

Fixes #6190
This commit is contained in:
Jonathan Rainville 2022-06-22 11:09:47 -04:00 committed by Iuri Matias
parent 6f14921c9b
commit 9ebe9ec2c5
16 changed files with 30 additions and 24 deletions

View File

@ -115,7 +115,8 @@ proc getChatDetails*(self: Controller, chatId: string): ChatDto =
proc getChannelGroups*(self: Controller): seq[ChannelGroupDto] =
return self.chatService.getChannelGroups()
proc getOneToOneChatNameAndImage*(self: Controller, chatId: string): tuple[name: string, image: string] =
proc getOneToOneChatNameAndImage*(self: Controller, chatId: string):
tuple[name: string, image: string, largeImage: string] =
return self.chatService.getOneToOneChatNameAndImage(chatId)
proc getMessageById*(self: Controller, chatId, messageId: string): MessageDto =

View File

@ -130,11 +130,11 @@ proc searchMessages*(self: Controller, searchTerm: string) =
self.messageService.asyncSearchMessages(communities, chats, self.searchTerm, false)
proc getOneToOneChatNameAndImage*(self: Controller, chatId: string):
tuple[name: string, image: string] =
tuple[name: string, image: string, largeImage: string] =
return self.chatService.getOneToOneChatNameAndImage(chatId)
proc getContactNameAndImage*(self: Controller, contactId: string):
tuple[name: string, image: string] =
tuple[name: string, image: string, largeImage: string] =
return self.contactsService.getContactNameAndImage(contactId)
proc addResultItemDetails*(self: Controller, itemId: string, sectionId = "", channelId = "", messageId = "") =

View File

@ -231,7 +231,7 @@ method onSearchMessagesDone*(self: Module, messages: seq[MessageDto]) =
continue
let chatDto = self.controller.getChatDetails("", m.chatId)
var (senderName, senderImage) = self.controller.getContactNameAndImage(m.`from`)
var (senderName, senderImage, _) = self.controller.getContactNameAndImage(m.`from`)
if(m.`from` == singletonInstance.userProfile.getPubKey()):
senderName = "You"

View File

@ -139,7 +139,7 @@ proc getChatDetails*(self: Controller): ChatDto =
proc getCommunityDetails*(self: Controller): CommunityDto =
return self.communityService.getCommunityById(self.sectionId)
proc getOneToOneChatNameAndImage*(self: Controller): tuple[name: string, image: string] =
proc getOneToOneChatNameAndImage*(self: Controller): tuple[name: string, image: string, largeImage: string] =
return self.chatService.getOneToOneChatNameAndImage(self.chatId)
proc belongsToCommunity*(self: Controller): bool =

View File

@ -176,7 +176,8 @@ proc getChatDetails*(self: Controller): ChatDto =
proc getCommunityDetails*(self: Controller): CommunityDto =
return self.communityService.getCommunityById(self.sectionId)
proc getOneToOneChatNameAndImage*(self: Controller): tuple[name: string, image: string] =
proc getOneToOneChatNameAndImage*(self: Controller):
tuple[name: string, image: string, largeImage: string] =
return self.chatService.getOneToOneChatNameAndImage(self.chatId)
proc belongsToCommunity*(self: Controller): bool =

View File

@ -98,12 +98,13 @@ proc createFetchMoreMessagesItem(self: Module): Item =
proc createChatIdentifierItem(self: Module): Item =
let chatDto = self.controller.getChatDetails()
var chatName = chatDto.name
var smallImage = ""
var chatIcon = ""
var senderIsAdded = false
if(chatDto.chatType == ChatType.OneToOne):
let sender = self.controller.getContactDetails(chatDto.id)
senderIsAdded = sender.details.added
(chatName, chatIcon) = self.controller.getOneToOneChatNameAndImage()
(chatName, smallImage, chatIcon) = self.controller.getOneToOneChatNameAndImage()
result = initItem(
CHAT_IDENTIFIER_MESSAGE_ID,

View File

@ -161,7 +161,7 @@ proc getMembersPublicKeys*(self: Controller): seq[string] =
return chatDto.members.map(x => x.id)
proc getContactNameAndImage*(self: Controller, contactId: string):
tuple[name: string, image: string] =
tuple[name: string, image: string, largeImage: string] =
return self.contactService.getContactNameAndImage(contactId)
proc getContactDetails*(self: Controller, contactId: string): ContactDetails =

View File

@ -240,7 +240,7 @@ proc removeCommunityChat*(self: Controller, itemId: string) =
self.communityService.deleteCommunityChat(self.getMySectionId(), itemId)
proc getOneToOneChatNameAndImage*(self: Controller, chatId: string):
tuple[name: string, image: string] =
tuple[name: string, image: string, largeImage: string] =
return self.chatService.getOneToOneChatNameAndImage(chatId)
proc createPublicChat*(self: Controller, chatId: string) =

View File

@ -132,7 +132,7 @@ proc setCommunityMuted*(self: Controller, communityId: string, muted: bool) =
self.communityService.setCommunityMuted(communityId, muted)
proc getContactNameAndImage*(self: Controller, contactId: string):
tuple[name: string, image: string] =
tuple[name: string, image: string, largeImage: string] =
return self.contactsService.getContactNameAndImage(contactId)
proc getContactDetails*(self: Controller, contactId: string): ContactDetails =

View File

@ -285,7 +285,7 @@ proc getContacts*(self: Controller, group: ContactsGroup): seq[ContactsDto] =
return self.contactsService.getContactsByGroup(group)
proc getContactNameAndImage*(self: Controller, contactId: string):
tuple[name: string, image: string] =
tuple[name: string, image: string, largeImage: string] =
return self.contactsService.getContactNameAndImage(contactId)
proc getContactDetails*(self: Controller, contactId: string): ContactDetails =

View File

@ -679,10 +679,10 @@ method communityEdited*[T](
method getContactDetailsAsJson*[T](self: Module[T], publicKey: string): string =
let contact = self.controller.getContact(publicKey)
let (name, image) = self.controller.getContactNameAndImage(contact.id)
let (name, _, _) = self.controller.getContactNameAndImage(contact.id)
let jsonObj = %* {
"displayName": name,
"displayIcon": image,
"displayIcon": contact.image.thumbnail,
"publicKey": contact.id,
"name": contact.name,
"ensVerified": contact.ensVerified,
@ -690,8 +690,8 @@ method getContactDetailsAsJson*[T](self: Module[T], publicKey: string): string =
"lastUpdated": contact.lastUpdated,
"lastUpdatedLocally": contact.lastUpdatedLocally,
"localNickname": contact.localNickname,
"thumbnailImage": contact.image.large,
"largeImage": contact.image.thumbnail,
"thumbnailImage": contact.image.thumbnail,
"largeImage": contact.image.large,
"isContact":contact.added,
"isBlocked":contact.blocked,
"requestReceived":contact.hasAddedUs,
@ -764,7 +764,7 @@ method osNotificationClicked*[T](self: Module[T], details: NotificationDetails)
echo "There is no particular action clicking on a notification informing you about rejection to join community"
method newCommunityMembershipRequestReceived*[T](self: Module[T], membershipRequest: CommunityMembershipRequestDto) =
let (contactName, _) = self.controller.getContactNameAndImage(membershipRequest.publicKey)
let (contactName, _, _) = self.controller.getContactNameAndImage(membershipRequest.publicKey)
let community = self.controller.getCommunityById(membershipRequest.communityId)
singletonInstance.globalEvents.newCommunityMembershipRequestNotification("New membership request",
fmt "{contactName} asks to join {community.name}", community.id)

View File

@ -60,7 +60,7 @@ proc getContact*(self: Controller, id: string): ContactsDto =
return self.contactsService.getContactById(id)
proc getContactNameAndImage*(self: Controller, contactId: string):
tuple[name: string, image: string] =
tuple[name: string, image: string, largeImage: string] =
return self.contactsService.getContactNameAndImage(contactId)
proc unblockContact*(self: Controller, publicKey: string) =

View File

@ -40,7 +40,7 @@ method delete*(self: Module) =
proc createItemFromPublicKey(self: Module, publicKey: string): UserItem =
let contact = self.controller.getContact(publicKey)
let (name, image) = self.controller.getContactNameAndImage(contact.id)
let (name, image, _) = self.controller.getContactNameAndImage(contact.id)
return initUserItem(
pubKey = contact.id,
@ -164,7 +164,7 @@ method contactUpdated*(self: Module, publicKey: string) =
self.removeIfExistsAndAddToAppropriateModel(publicKey)
method contactNicknameChanged*(self: Module, publicKey: string) =
let (name, _) = self.controller.getContactNameAndImage(publicKey)
let (name, _, _) = self.controller.getContactNameAndImage(publicKey)
self.view.myMutualContactsModel().updateName(publicKey, name)
self.view.receivedContactRequestsModel().updateName(publicKey, name)
self.view.sentContactRequestsModel().updateName(publicKey, name)

View File

@ -247,7 +247,7 @@ QtObject:
return self.chats[chatId]
proc getOneToOneChatNameAndImage*(self: Service, chatId: string):
tuple[name: string, image: string] =
tuple[name: string, image: string, largeImage: string] =
return self.contactService.getContactNameAndImage(chatId)
proc createChatFromResponse(self: Service, response: RpcResponse[JsonNode]): tuple[chatDto: ChatDto, success: bool] =

View File

@ -276,13 +276,16 @@ QtObject:
return self.contactsStatus[publicKey]
proc getContactNameAndImage*(self: Service, publicKey: string): tuple[name: string, image: string] =
proc getContactNameAndImage*(self: Service, publicKey: string):
tuple[name: 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()
if(contactDto.image.thumbnail.len > 0):
result.image = contactDto.image.thumbnail
if(contactDto.image.large.len > 0):
result.largeImage = contactDto.image.large
proc saveContact(self: Service, contact: ContactsDto) =
# we must keep local contacts updated
@ -461,7 +464,7 @@ QtObject:
proc getContactDetails*(self: Service, pubKey: string): ContactDetails =
result = ContactDetails()
let (name, icon) = self.getContactNameAndImage(pubKey)
let (name, icon, _) = self.getContactNameAndImage(pubKey)
result.displayName = name
result.icon = icon
result.isCurrentUser = pubKey == singletonInstance.userProfile.getPubKey()

View File

@ -192,7 +192,7 @@ Column {
messageContextMenu.messageSenderId = obj.senderId
messageContextMenu.selectedUserPublicKey = obj.senderId
messageContextMenu.selectedUserDisplayName = obj.senderDisplayName
messageContextMenu.selectedUserIcon = obj.senderIcon
messageContextMenu.selectedUserIcon = obj.senderIconToShow
}
@ -289,7 +289,7 @@ Column {
chatColor: root.messageStore.getChatColor()
chatEmoji: root.channelEmoji
amIChatAdmin: root.messageStore.amIChatAdmin()
chatIcon: root.senderIcon
chatIcon: root.senderIconToShow
}
}