fix: do not display ENS name when not ENS verified

- expose "isEnsVerified" as model role
- fix returning "ensName" when the user is not ensVerified
- react to nickname updates correctly
- fix sorting in the user/member list view
This commit is contained in:
Lukáš Tinkl 2023-04-19 18:48:57 +02:00 committed by Lukáš Tinkl
parent c209e7c282
commit 038ab08765
32 changed files with 122 additions and 77 deletions

View File

@ -79,6 +79,7 @@ method contactUpdated*(self: Module, publicKey: string) =
pubKey = publicKey, pubKey = publicKey,
displayName = contactDetails.details.displayName, displayName = contactDetails.details.displayName,
ensName = contactDetails.details.name, ensName = contactDetails.details.name,
isEnsVerified = contactDetails.details.ensVerified,
localNickname = contactDetails.details.localNickname, localNickname = contactDetails.details.localNickname,
alias = contactDetails.details.alias, alias = contactDetails.details.alias,
icon = contactDetails.icon, icon = contactDetails.icon,
@ -120,6 +121,7 @@ method addChatMember(self: Module, member: ChatMember) =
pubKey = member.id, pubKey = member.id,
displayName = contactDetails.details.displayName, displayName = contactDetails.details.displayName,
ensName = contactDetails.details.name, ensName = contactDetails.details.name,
isEnsVerified = contactDetails.details.ensVerified,
localNickname = contactDetails.details.localNickname, localNickname = contactDetails.details.localNickname,
alias = contactDetails.details.alias, alias = contactDetails.details.alias,
icon = contactDetails.icon, icon = contactDetails.icon,
@ -158,6 +160,7 @@ method onChatMemberUpdated*(self: Module, publicKey: string, admin: bool, joined
pubKey = publicKey, pubKey = publicKey,
displayName = contactDetails.details.displayName, displayName = contactDetails.details.displayName,
ensName = contactDetails.details.name, ensName = contactDetails.details.name,
isEnsVerified = contactDetails.details.ensVerified,
localNickname = contactDetails.details.localNickname, localNickname = contactDetails.details.localNickname,
alias = contactDetails.details.alias, alias = contactDetails.details.alias,
icon = contactDetails.icon, icon = contactDetails.icon,
@ -177,4 +180,4 @@ method removeGroupMembers*(self: Module, pubKeys: seq[string]) =
method updateMembersList*(self: Module) = method updateMembersList*(self: Module) =
let members = self.controller.getChatMembers() let members = self.controller.getChatMembers()
for member in members: for member in members:
self.addChatMember(member) self.addChatMember(member)

View File

@ -58,6 +58,7 @@ QtObject:
pubKey = pubKey, pubKey = pubKey,
displayName = displayName, displayName = displayName,
ensName = "", ensName = "",
isEnsVerified = false,
localNickname = "", localNickname = "",
alias = "", alias = "",
icon = "", icon = "",

View File

@ -247,10 +247,12 @@ proc createItemFromPublicKey(self: Module, publicKey: string): UserItem =
pubKey = contactDetails.details.id, pubKey = contactDetails.details.id,
displayName = contactDetails.details.displayName, displayName = contactDetails.details.displayName,
ensName = contactDetails.details.name, ensName = contactDetails.details.name,
isEnsVerified = contactDetails.details.ensVerified,
localNickname = contactDetails.details.localNickname, localNickname = contactDetails.details.localNickname,
alias = contactDetails.details.alias, alias = contactDetails.details.alias,
icon = contactDetails.icon, icon = contactDetails.icon,
colorId = contactDetails.colorId, colorId = contactDetails.colorId,
colorHash = contactDetails.colorHash,
onlineStatus = toOnlineStatus(self.controller.getStatusForContactWithId(publicKey).statusType), onlineStatus = toOnlineStatus(self.controller.getStatusForContactWithId(publicKey).statusType),
isContact = contactDetails.details.isContact(), isContact = contactDetails.details.isContact(),
isVerified = contactDetails.details.isContactVerified(), isVerified = contactDetails.details.isContactVerified(),

View File

@ -123,6 +123,7 @@ proc createMemberItem(self: Module, memberId, requestId: string): MemberItem =
pubKey = memberId, pubKey = memberId,
displayName = contactDetails.details.displayName, displayName = contactDetails.details.displayName,
ensName = contactDetails.details.name, ensName = contactDetails.details.name,
isEnsVerified = contactDetails.details.ensVerified,
localNickname = contactDetails.details.localNickname, localNickname = contactDetails.details.localNickname,
alias = contactDetails.details.alias, alias = contactDetails.details.alias,
icon = contactDetails.icon, icon = contactDetails.icon,

View File

@ -239,6 +239,9 @@ method getAppSearchModule*(self: AccessInterface): QVariant {.base.} =
method getContactDetailsAsJson*(self: AccessInterface, publicKey: string, getVerificationRequest: bool): string {.base.} = method getContactDetailsAsJson*(self: AccessInterface, publicKey: string, getVerificationRequest: bool): string {.base.} =
raise newException(ValueError, "No implementation available") raise newException(ValueError, "No implementation available")
method isEnsVerified*(self: AccessInterface, publicKey: string): bool {.base.} =
raise newException(ValueError, "No implementation available")
method communityDataImported*(self: AccessInterface, community: CommunityDto) {.base.} = method communityDataImported*(self: AccessInterface, community: CommunityDto) {.base.} =
raise newException(ValueError, "No implementation available") raise newException(ValueError, "No implementation available")

View File

@ -293,6 +293,7 @@ proc createChannelGroupItem[T](self: Module[T], channelGroup: ChannelGroupDto):
pubKey = member.id, pubKey = member.id,
displayName = contactDetails.details.displayName, displayName = contactDetails.details.displayName,
ensName = contactDetails.details.name, ensName = contactDetails.details.name,
isEnsVerified = contactDetails.details.ensVerified,
localNickname = contactDetails.details.localNickname, localNickname = contactDetails.details.localNickname,
alias = contactDetails.details.alias, alias = contactDetails.details.alias,
icon = contactDetails.icon, icon = contactDetails.icon,
@ -321,6 +322,7 @@ proc createChannelGroupItem[T](self: Module[T], channelGroup: ChannelGroupDto):
pubKey = bannedMemberId, pubKey = bannedMemberId,
displayName = contactDetails.details.displayName, displayName = contactDetails.details.displayName,
ensName = contactDetails.details.name, ensName = contactDetails.details.name,
isEnsVerified = contactDetails.details.ensVerified,
localNickname = contactDetails.details.localNickname, localNickname = contactDetails.details.localNickname,
alias = contactDetails.details.alias, alias = contactDetails.details.alias,
icon = contactDetails.icon, icon = contactDetails.icon,
@ -338,6 +340,7 @@ proc createChannelGroupItem[T](self: Module[T], channelGroup: ChannelGroupDto):
pubKey = requestDto.publicKey, pubKey = requestDto.publicKey,
displayName = contactDetails.details.displayName, displayName = contactDetails.details.displayName,
ensName = contactDetails.details.name, ensName = contactDetails.details.name,
isEnsVerified = contactDetails.details.ensVerified,
localNickname = contactDetails.details.localNickname, localNickname = contactDetails.details.localNickname,
alias = contactDetails.details.alias, alias = contactDetails.details.alias,
icon = contactDetails.icon, icon = contactDetails.icon,
@ -356,6 +359,7 @@ proc createChannelGroupItem[T](self: Module[T], channelGroup: ChannelGroupDto):
pubKey = requestDto.publicKey, pubKey = requestDto.publicKey,
displayName = contactDetails.details.displayName, displayName = contactDetails.details.displayName,
ensName = contactDetails.details.name, ensName = contactDetails.details.name,
isEnsVerified = contactDetails.details.ensVerified,
localNickname = contactDetails.details.localNickname, localNickname = contactDetails.details.localNickname,
alias = contactDetails.details.alias, alias = contactDetails.details.alias,
icon = contactDetails.icon, icon = contactDetails.icon,
@ -955,6 +959,9 @@ method getContactDetailsAsJson*[T](self: Module[T], publicKey: string, getVerifi
} }
return $jsonObj return $jsonObj
method isEnsVerified*[T](self: Module[T], publicKey: string): bool =
return self.controller.getContact(publicKey).ensVerified
method communityDataImported*[T](self: Module[T], community: CommunityDto) = method communityDataImported*[T](self: Module[T], community: CommunityDto) =
if community.id == self.statusUrlCommunityToSpectate: if community.id == self.statusUrlCommunityToSpectate:
self.statusUrlCommunityToSpectate = "" self.statusUrlCommunityToSpectate = ""
@ -1018,6 +1025,7 @@ method contactUpdated*[T](self: Module[T], publicKey: string) =
publicKey, publicKey,
contactDetails.details.displayName, contactDetails.details.displayName,
contactDetails.details.name, contactDetails.details.name,
contactDetails.details.ensVerified,
contactDetails.details.localNickname, contactDetails.details.localNickname,
contactDetails.details.alias, contactDetails.details.alias,
contactDetails.icon, contactDetails.icon,

View File

@ -41,22 +41,23 @@ method delete*(self: Module) =
self.view.delete self.view.delete
proc createItemFromPublicKey(self: Module, publicKey: string): UserItem = proc createItemFromPublicKey(self: Module, publicKey: string): UserItem =
let contact = self.controller.getContact(publicKey) let contactDetails = self.controller.getContactDetails(publicKey)
let contactDetails = self.controller.getContactDetails(contact.id)
return initUserItem( return initUserItem(
pubKey = contact.id, pubKey = contactDetails.details.id,
displayName = contactDetails.details.displayName, displayName = contactDetails.details.displayName,
ensName = contactDetails.details.name, ensName = contactDetails.details.name,
isEnsVerified = contactDetails.details.ensVerified,
localNickname = contactDetails.details.localNickname, localNickname = contactDetails.details.localNickname,
alias = contactDetails.details.alias, alias = contactDetails.details.alias,
icon = contactDetails.icon, icon = contactDetails.icon,
colorId = contactDetails.colorId, colorId = contactDetails.colorId,
colorHash = contactDetails.colorHash,
onlineStatus = toOnlineStatus(self.controller.getStatusForContactWithId(publicKey).statusType), onlineStatus = toOnlineStatus(self.controller.getStatusForContactWithId(publicKey).statusType),
isContact = contact.isContact(), isContact = contactDetails.details.isContact(),
isBlocked = contact.isBlocked(), isVerified = contactDetails.details.isContactVerified(),
isVerified = contact.isContactVerified(), isUntrustworthy = contactDetails.details.isContactUntrustworthy(),
isUntrustworthy = contact.isContactUntrustworthy() isBlocked = contactDetails.details.isBlocked(),
) )
proc buildModel(self: Module, model: Model, group: ContactsGroup) = proc buildModel(self: Module, model: Model, group: ContactsGroup) =
@ -186,14 +187,18 @@ method contactsStatusUpdated*(self: Module, statusUpdates: seq[StatusUpdateDto])
self.view.myMutualContactsModel().setOnlineStatus(s.publicKey, status) self.view.myMutualContactsModel().setOnlineStatus(s.publicKey, status)
method contactNicknameChanged*(self: Module, publicKey: string) = method contactNicknameChanged*(self: Module, publicKey: string) =
let (name, _, _) = self.controller.getContactNameAndImage(publicKey) let contactDetails = self.controller.getContactDetails(publicKey)
self.view.myMutualContactsModel().updateName(publicKey, name) let displayName = contactDetails.details.displayName
self.view.receivedContactRequestsModel().updateName(publicKey, name) let ensName = contactDetails.details.name
self.view.sentContactRequestsModel().updateName(publicKey, name) let localNickname = contactDetails.details.localNickname
self.view.myMutualContactsModel().setName(publicKey, displayName, ensName, localNickname)
self.view.receivedContactRequestsModel().setName(publicKey, displayName, ensName, localNickname)
self.view.sentContactRequestsModel().setName(publicKey, displayName, ensName, localNickname)
# Temporary commented until we provide appropriate flags on the `status-go` side to cover all sections. # Temporary commented until we provide appropriate flags on the `status-go` side to cover all sections.
# self.view.receivedButRejectedContactRequestsModel().updateName(publicKey, name) # self.view.receivedButRejectedContactRequestsModel().setName(publicKey, displayName, ensName, localNickname)
# self.view.sentButRejectedContactRequestsModel().updateName(publicKey, name) # self.view.sentButRejectedContactRequestsModel().setName(publicKey, displayName, ensName, localNickname)
self.view.blockedContactsModel().updateName(publicKey, name) self.view.blockedContactsModel().setName(publicKey, displayName, ensName, localNickname)
method contactTrustStatusChanged*(self: Module, publicKey: string, isUntrustworthy: bool) = method contactTrustStatusChanged*(self: Module, publicKey: string, isUntrustworthy: bool) =
self.view.myMutualContactsModel().updateTrustStatus(publicKey, isUntrustworthy) self.view.myMutualContactsModel().updateTrustStatus(publicKey, isUntrustworthy)
@ -282,4 +287,4 @@ method requestContactInfo*(self: Module, publicKey: string) =
self.controller.requestContactInfo(publicKey) self.controller.requestContactInfo(publicKey)
method onContactInfoRequestFinished*(self: Module, publicKey: string, ok: bool) = method onContactInfoRequestFinished*(self: Module, publicKey: string, ok: bool) =
self.view.onContactInfoRequestFinished(publicKey, ok) self.view.onContactInfoRequestFinished(publicKey, ok)

View File

@ -210,6 +210,9 @@ QtObject:
proc getContactDetailsAsJson(self: View, publicKey: string, getVerificationRequest: bool): string {.slot.} = proc getContactDetailsAsJson(self: View, publicKey: string, getVerificationRequest: bool): string {.slot.} =
return self.delegate.getContactDetailsAsJson(publicKey, getVerificationRequest) return self.delegate.getContactDetailsAsJson(publicKey, getVerificationRequest)
proc isEnsVerified(self:View, publicKey: string): bool {.slot.} =
return self.delegate.isEnsVerified(publicKey)
proc resolveENS*(self: View, ensName: string, uuid: string) {.slot.} = proc resolveENS*(self: View, ensName: string, uuid: string) {.slot.} =
self.delegate.resolveENS(ensName, uuid) self.delegate.resolveENS(ensName, uuid)

View File

@ -17,6 +17,7 @@ proc initMemberItem*(
pubKey: string, pubKey: string,
displayName: string, displayName: string,
ensName: string, ensName: string,
isEnsVerified: bool,
localNickname: string, localNickname: string,
alias: string, alias: string,
icon: string, icon: string,
@ -44,6 +45,7 @@ proc initMemberItem*(
pubKey = pubKey, pubKey = pubKey,
displayName = displayName, displayName = displayName,
ensName = ensName, ensName = ensName,
isEnsVerified = isEnsVerified,
localNickname = localNickname, localNickname = localNickname,
alias = alias, alias = alias,
icon = icon, icon = icon,
@ -64,6 +66,7 @@ proc `$`*(self: MemberItem): string =
pubKey: {self.pubkey}, pubKey: {self.pubkey},
displayName: {self.displayName}, displayName: {self.displayName},
ensName: {self.ensName}, ensName: {self.ensName},
isEnsVerified: {self.isEnsVerified},
localNickname: {self.localNickname}, localNickname: {self.localNickname},
alias: {self.alias}, alias: {self.alias},
icon: {self.icon}, icon: {self.icon},

View File

@ -11,6 +11,7 @@ type
PubKey = UserRole + 1 PubKey = UserRole + 1
DisplayName DisplayName
EnsName EnsName
IsEnsVerified
LocalNickname LocalNickname
Alias Alias
Icon Icon
@ -77,6 +78,7 @@ QtObject:
ModelRole.PubKey.int: "pubKey", ModelRole.PubKey.int: "pubKey",
ModelRole.DisplayName.int: "displayName", ModelRole.DisplayName.int: "displayName",
ModelRole.EnsName.int: "ensName", ModelRole.EnsName.int: "ensName",
ModelRole.IsEnsVerified.int: "isEnsVerified",
ModelRole.LocalNickname.int: "localNickname", ModelRole.LocalNickname.int: "localNickname",
ModelRole.Alias.int: "alias", ModelRole.Alias.int: "alias",
ModelRole.Icon.int: "icon", ModelRole.Icon.int: "icon",
@ -113,6 +115,8 @@ QtObject:
result = newQVariant(item.displayName) result = newQVariant(item.displayName)
of ModelRole.EnsName: of ModelRole.EnsName:
result = newQVariant(item.ensName) result = newQVariant(item.ensName)
of ModelRole.IsEnsVerified:
result = newQVariant(item.isEnsVerified)
of ModelRole.LocalNickname: of ModelRole.LocalNickname:
result = newQVariant(item.localNickname) result = newQVariant(item.localNickname)
of ModelRole.Alias: of ModelRole.Alias:
@ -205,6 +209,7 @@ QtObject:
pubKey: string, pubKey: string,
displayName: string, displayName: string,
ensName: string, ensName: string,
isEnsVerified: bool,
localNickname: string, localNickname: string,
alias: string, alias: string,
icon: string, icon: string,
@ -220,6 +225,7 @@ QtObject:
self.items[ind].displayName = displayName self.items[ind].displayName = displayName
self.items[ind].ensName = ensName self.items[ind].ensName = ensName
self.items[ind].isEnsVerified = isEnsVerified
self.items[ind].localNickname = localNickname self.items[ind].localNickname = localNickname
self.items[ind].alias = alias self.items[ind].alias = alias
self.items[ind].icon = icon self.items[ind].icon = icon
@ -232,6 +238,7 @@ QtObject:
let index = self.createIndex(ind, 0, nil) let index = self.createIndex(ind, 0, nil)
self.dataChanged(index, index, @[ self.dataChanged(index, index, @[
ModelRole.DisplayName.int, ModelRole.DisplayName.int,
ModelRole.IsEnsVerified.int,
ModelRole.EnsName.int, ModelRole.EnsName.int,
ModelRole.LocalNickname.int, ModelRole.LocalNickname.int,
ModelRole.Alias.int, ModelRole.Alias.int,
@ -248,6 +255,7 @@ QtObject:
pubKey: string, pubKey: string,
displayName: string, displayName: string,
ensName: string, ensName: string,
isEnsVerified: bool,
localNickname: string, localNickname: string,
alias: string, alias: string,
icon: string, icon: string,
@ -261,6 +269,7 @@ QtObject:
self.items[ind].displayName = displayName self.items[ind].displayName = displayName
self.items[ind].ensName = ensName self.items[ind].ensName = ensName
self.items[ind].isEnsVerified = isEnsVerified
self.items[ind].localNickname = localNickname self.items[ind].localNickname = localNickname
self.items[ind].alias = alias self.items[ind].alias = alias
self.items[ind].icon = icon self.items[ind].icon = icon
@ -272,6 +281,7 @@ QtObject:
self.dataChanged(index, index, @[ self.dataChanged(index, index, @[
ModelRole.DisplayName.int, ModelRole.DisplayName.int,
ModelRole.EnsName.int, ModelRole.EnsName.int,
ModelRole.IsEnsVerified.int,
ModelRole.LocalNickname.int, ModelRole.LocalNickname.int,
ModelRole.Alias.int, ModelRole.Alias.int,
ModelRole.Icon.int, ModelRole.Icon.int,

View File

@ -163,15 +163,15 @@ QtObject:
proc pinned*(self: MessageItem): bool {.slot.} = result = ?.self.messageItem.pinned proc pinned*(self: MessageItem): bool {.slot.} = result = ?.self.messageItem.pinned
QtProperty[bool] pinned: QtProperty[bool] pinned:
read = bool read = pinned
proc editMode*(self: MessageItem): bool {.slot.} = result = ?.self.messageItem.editMode proc editMode*(self: MessageItem): bool {.slot.} = result = ?.self.messageItem.editMode
QtProperty[bool] editMode: QtProperty[bool] editMode:
read = bool read = editMode
proc isEdited*(self: MessageItem): bool {.slot.} = result = ?.self.messageItem.isEdited proc isEdited*(self: MessageItem): bool {.slot.} = result = ?.self.messageItem.isEdited
QtProperty[bool] isEdited: QtProperty[bool] isEdited:
read = bool read = isEdited
# this is not the greatest approach, but aligns with the rest of the code # this is not the greatest approach, but aligns with the rest of the code
proc communityId*(self: MessageItem): string {.slot.} = result = ?.self.messageItem.communityId proc communityId*(self: MessageItem): string {.slot.} = result = ?.self.messageItem.communityId

View File

@ -249,13 +249,14 @@ QtObject:
pubkey: string, pubkey: string,
name: string, name: string,
ensName: string, ensName: string,
isEnsVerified: bool,
localNickname: string, localNickname: string,
alias: string, alias: string,
image: string, image: string,
isContact: bool, isContact: bool,
isVerified: bool, isVerified: bool,
isUntrustworthy: bool) = isUntrustworthy: bool) =
self.item.updateMember(pubkey, name, ensName, localNickname, alias, image, isContact, self.item.updateMember(pubkey, name, ensName, isEnsVerified, localNickname, alias, image, isContact,
isVerified, isUntrustworthy) isVerified, isUntrustworthy)
proc pendingRequestsToJoin(self: SectionDetails): QVariant {.slot.} = proc pendingRequestsToJoin(self: SectionDetails): QVariant {.slot.} =

View File

@ -278,13 +278,14 @@ proc updateMember*(
pubkey: string, pubkey: string,
name: string, name: string,
ensName: string, ensName: string,
isEnsVerified: bool,
nickname: string, nickname: string,
alias: string, alias: string,
image: string, image: string,
isContact: bool, isContact: bool,
isVerified: bool, isVerified: bool,
isUntrustworthy: bool) = isUntrustworthy: bool) =
self.membersModel.updateItem(pubkey, name, ensName, nickname, alias, image, isContact, self.membersModel.updateItem(pubkey, name, ensName, isEnsVerified, nickname, alias, image, isContact,
isVerified, isUntrustworthy) isVerified, isUntrustworthy)
proc bannedMembers*(self: SectionItem): member_model.Model {.inline.} = proc bannedMembers*(self: SectionItem): member_model.Model {.inline.} =

View File

@ -23,6 +23,7 @@ type
pubKey: string pubKey: string
displayName: string displayName: string
ensName: string ensName: string
isEnsVerified: bool
localNickname: string localNickname: string
alias: string alias: string
icon: string icon: string
@ -41,6 +42,7 @@ proc setup*(self: UserItem,
pubKey: string, pubKey: string,
displayName: string, displayName: string,
ensName: string, ensName: string,
isEnsVerified: bool,
localNickname: string, localNickname: string,
alias: string, alias: string,
icon: string, icon: string,
@ -58,6 +60,7 @@ proc setup*(self: UserItem,
self.pubKey = pubKey self.pubKey = pubKey
self.displayName = displayName self.displayName = displayName
self.ensName = ensName self.ensName = ensName
self.isEnsVerified = isEnsVerified
self.localNickname = localNickname self.localNickname = localNickname
self.alias = alias self.alias = alias
self.icon = icon self.icon = icon
@ -77,6 +80,7 @@ proc initUserItem*(
pubKey: string, pubKey: string,
displayName: string, displayName: string,
ensName: string, ensName: string,
isEnsVerified: bool,
localNickname: string, localNickname: string,
alias: string, alias: string,
icon: string, icon: string,
@ -96,6 +100,7 @@ proc initUserItem*(
pubKey = pubKey, pubKey = pubKey,
displayName = displayName, displayName = displayName,
ensName = ensName, ensName = ensName,
isEnsVerified = isEnsVerified,
localNickname = localNickname, localNickname = localNickname,
alias = alias, alias = alias,
icon = icon, icon = icon,
@ -115,6 +120,7 @@ proc `$`*(self: UserItem): string =
pubKey: {self.pubkey}, pubKey: {self.pubkey},
displayName: {self.displayName}, displayName: {self.displayName},
ensName: {self.ensName}, ensName: {self.ensName},
isEnsVerified: {self.isEnsVerified},
localNickname: {self.localNickname}, localNickname: {self.localNickname},
alias: {self.alias}, alias: {self.alias},
icon: {self.icon}, icon: {self.icon},
@ -140,11 +146,17 @@ proc `displayName=`*(self: UserItem, value: string) {.inline.} =
self.displayName = value self.displayName = value
proc ensName*(self: UserItem): string {.inline.} = proc ensName*(self: UserItem): string {.inline.} =
self.ensName if self.isEnsVerified: self.ensName else: ""
proc `ensName=`*(self: UserItem, value: string) {.inline.} = proc `ensName=`*(self: UserItem, value: string) {.inline.} =
self.ensName = value self.ensName = value
proc isEnsVerified*(self: UserItem): bool {.inline.} =
self.isEnsVerified
proc `isEnsVerified=`*(self: UserItem, value: bool) {.inline.} =
self.isEnsVerified = value
proc localNickname*(self: UserItem): string {.inline.} = proc localNickname*(self: UserItem): string {.inline.} =
self.localNickname self.localNickname
@ -170,7 +182,7 @@ proc `colorId=`*(self: UserItem, value: int) {.inline.} =
self.colorId = value self.colorId = value
proc colorHash*(self: UserItem): string {.inline.} = proc colorHash*(self: UserItem): string {.inline.} =
self.colorHash if not self.isEnsVerified: self.colorHash else: ""
proc `colorHash=`*(self: UserItem, value: string) {.inline.} = proc `colorHash=`*(self: UserItem, value: string) {.inline.} =
self.colorHash = value self.colorHash = value

View File

@ -8,6 +8,7 @@ type
PubKey = UserRole + 1 PubKey = UserRole + 1
DisplayName DisplayName
EnsName EnsName
IsEnsVerified
LocalNickname LocalNickname
Alias Alias
Icon Icon
@ -67,6 +68,7 @@ QtObject:
ModelRole.PubKey.int: "pubKey", ModelRole.PubKey.int: "pubKey",
ModelRole.DisplayName.int: "displayName", ModelRole.DisplayName.int: "displayName",
ModelRole.EnsName.int: "ensName", ModelRole.EnsName.int: "ensName",
ModelRole.IsEnsVerified.int: "isEnsVerified",
ModelRole.LocalNickname.int: "localNickname", ModelRole.LocalNickname.int: "localNickname",
ModelRole.Alias.int: "alias", ModelRole.Alias.int: "alias",
ModelRole.Icon.int: "icon", ModelRole.Icon.int: "icon",
@ -99,6 +101,8 @@ QtObject:
result = newQVariant(item.displayName) result = newQVariant(item.displayName)
of ModelRole.EnsName: of ModelRole.EnsName:
result = newQVariant(item.ensName) result = newQVariant(item.ensName)
of ModelRole.IsEnsVerified:
result = newQVariant(item.isEnsVerified)
of ModelRole.LocalNickname: of ModelRole.LocalNickname:
result = newQVariant(item.localNickname) result = newQVariant(item.localNickname)
of ModelRole.Alias: of ModelRole.Alias:
@ -227,6 +231,7 @@ QtObject:
pubKey: string, pubKey: string,
displayName: string, displayName: string,
ensName: string, ensName: string,
isEnsVerified: bool,
localNickname: string, localNickname: string,
alias: string, alias: string,
icon: string, icon: string,
@ -238,6 +243,7 @@ QtObject:
self.items[ind].displayName = displayName self.items[ind].displayName = displayName
self.items[ind].ensName = ensName self.items[ind].ensName = ensName
self.items[ind].isEnsVerified = isEnsVerified
self.items[ind].localNickname = localNickname self.items[ind].localNickname = localNickname
self.items[ind].alias = alias self.items[ind].alias = alias
self.items[ind].icon = icon self.items[ind].icon = icon
@ -247,6 +253,7 @@ QtObject:
self.dataChanged(index, index, @[ self.dataChanged(index, index, @[
ModelRole.DisplayName.int, ModelRole.DisplayName.int,
ModelRole.EnsName.int, ModelRole.EnsName.int,
ModelRole.IsEnsVerified.int,
ModelRole.LocalNickname.int, ModelRole.LocalNickname.int,
ModelRole.Alias.int, ModelRole.Alias.int,
ModelRole.Icon.int, ModelRole.Icon.int,
@ -254,23 +261,6 @@ QtObject:
]) ])
self.itemChanged(pubKey) self.itemChanged(pubKey)
proc updateName*(
self: Model,
pubKey: string,
displayName: string
) =
let ind = self.findIndexByPubKey(pubKey)
if(ind == -1):
return
self.items[ind].displayName = displayName
let index = self.createIndex(ind, 0, nil)
self.dataChanged(index, index, @[
ModelRole.DisplayName.int
])
self.itemChanged(pubKey)
proc updateIncomingRequestStatus*( proc updateIncomingRequestStatus*(
self: Model, self: Model,
pubKey: string, pubKey: string,

View File

@ -133,8 +133,10 @@ proc toVerificationRequest*(jsonObj: JsonNode): VerificationRequest =
proc toContactsDto*(jsonObj: JsonNode): ContactsDto = proc toContactsDto*(jsonObj: JsonNode): ContactsDto =
result = ContactsDto() result = ContactsDto()
discard jsonObj.getProp("id", result.id) discard jsonObj.getProp("id", result.id)
discard jsonObj.getProp("name", result.name)
discard jsonObj.getProp("ensVerified", result.ensVerified) discard jsonObj.getProp("ensVerified", result.ensVerified)
result.name = ""
if (result.ensVerified):
discard jsonObj.getProp("name", result.name)
discard jsonObj.getProp("displayName", result.displayName) discard jsonObj.getProp("displayName", result.displayName)
discard jsonObj.getProp("alias", result.alias) discard jsonObj.getProp("alias", result.alias)
discard jsonObj.getProp("lastUpdated", result.lastUpdated) discard jsonObj.getProp("lastUpdated", result.lastUpdated)

View File

@ -570,7 +570,7 @@ QtObject:
result.isCurrentUser = pubKey == singletonInstance.userProfile.getPubKey() result.isCurrentUser = pubKey == singletonInstance.userProfile.getPubKey()
result.details = contactDto result.details = contactDto
if not contactDto.ensVerified: if not contactDto.ensVerified:
result.colorHash = procs_from_visual_identity_service.getColorHashAsJson(pubKey) result.colorHash = procs_from_visual_identity_service.getColorHashAsJson(pubKey)
proc markUntrustworthy*(self: Service, publicKey: string) = proc markUntrustworthy*(self: Service, publicKey: string) =
let response = status_contacts.markUntrustworthy(publicKey) let response = status_contacts.markUntrustworthy(publicKey)
@ -791,4 +791,4 @@ QtObject:
) )
self.threadpool.start(arg) self.threadpool.start(arg)
except Exception as e: except Exception as e:
error "Error requesting contact info", msg = e.msg, pubkey error "Error requesting contact info", msg = e.msg, pubkey

View File

@ -108,16 +108,16 @@ Item {
Loader { Loader {
id: tertiaryDetailTextLoader id: tertiaryDetailTextLoader
active: !root.amISender && root.messageOriginInfo === "" active: !root.amISender && root.messageOriginInfo === "" && !!root.tertiaryDetail
visible: active
asynchronous: true asynchronous: true
sourceComponent: StatusBaseText { sourceComponent: StatusBaseText {
id: tertiaryDetailText
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
font.pixelSize: Theme.asideTextFontSize font.pixelSize: Theme.asideTextFontSize
visible: text visible: text
elide: Text.ElideMiddle elide: Text.ElideMiddle
color: Theme.palette.baseColor1 color: Theme.palette.baseColor1
text: root.tertiaryDetail ? Utils.elideText(root.tertiaryDetail, 5, 3) : "" text: Utils.elideText(root.tertiaryDetail, 5, 3)
} }
} }

View File

@ -60,13 +60,21 @@ Item {
model: SortFilterProxyModel { model: SortFilterProxyModel {
sourceModel: root.usersModel sourceModel: root.usersModel
proxyRoles: ExpressionRole {
function displayNameProxy(nickname, ensName, displayName, aliasName) {
return ProfileUtils.displayName(nickname, ensName, displayName, aliasName)
}
name: "preferredDisplayName"
expression: displayNameProxy(model.localNickname, model.ensName, model.displayName, model.alias)
}
sorters: [ sorters: [
RoleSorter { RoleSorter {
roleName: "onlineStatus" roleName: "onlineStatus"
sortOrder: Qt.DescendingOrder sortOrder: Qt.DescendingOrder
}, },
StringSorter { StringSorter {
roleName: "displayName" roleName: "preferredDisplayName"
caseSensitivity: Qt.CaseInsensitive caseSensitivity: Qt.CaseInsensitive
} }
] ]
@ -74,11 +82,10 @@ Item {
section.property: "onlineStatus" section.property: "onlineStatus"
section.delegate: (root.width > 58) ? sectionDelegateComponent : null section.delegate: (root.width > 58) ? sectionDelegateComponent : null
delegate: StatusMemberListItem { delegate: StatusMemberListItem {
readonly property bool ensVerified: Utils.isEnsVerified(model.pubKey)
width: ListView.view.width width: ListView.view.width
nickName: model.localNickname nickName: model.localNickname
userName: ProfileUtils.displayName("", model.ensName, model.displayName, model.alias) userName: ProfileUtils.displayName("", model.ensName, model.displayName, model.alias)
pubKey: ensVerified ? "" : Utils.getCompressedPk(model.pubKey) pubKey: model.isEnsVerified ? "" : Utils.getCompressedPk(model.pubKey)
isContact: model.isContact isContact: model.isContact
isVerified: model.isVerified isVerified: model.isVerified
isUntrustworthy: model.isUntrustworthy isUntrustworthy: model.isUntrustworthy

View File

@ -51,7 +51,7 @@ Item {
rightPadding: 0 rightPadding: 0
placeholderText: root.placeholderText placeholderText: root.placeholderText
input.asset.name: "search" input.asset.name: "search"
enabled: model.count > 0 enabled: !!model && model.count > 0
} }
ListView { ListView {
@ -131,7 +131,7 @@ Item {
height: visible ? implicitHeight : 0 height: visible ? implicitHeight : 0
color: "transparent" color: "transparent"
pubKey: model.ensName ? "" : Utils.getElidedCompressedPk(model.pubKey) pubKey: model.isEnsVerified ? "" : Utils.getElidedCompressedPk(model.pubKey)
nickName: model.localNickname nickName: model.localNickname
userName: ProfileUtils.displayName("", model.ensName, model.displayName, model.alias) userName: ProfileUtils.displayName("", model.ensName, model.displayName, model.alias)
status: model.onlineStatus status: model.onlineStatus

View File

@ -35,14 +35,12 @@ ColumnLayout {
Layout.rightMargin: Style.current.padding Layout.rightMargin: Style.current.padding
} }
StatusInput { SearchBox {
id: filterInput id: filterInput
placeholderText: qsTr("Search contacts") placeholderText: qsTr("Search contacts")
maximumHeight: 36 maximumHeight: 36
topPadding: 0 topPadding: 0
bottomPadding: 0 bottomPadding: 0
input.asset.name: "search"
input.clearable: true
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: Style.current.bigPadding Layout.topMargin: Style.current.bigPadding
Layout.bottomMargin: Style.current.padding Layout.bottomMargin: Style.current.padding

View File

@ -467,6 +467,7 @@ StatusSectionLayout {
MessageContextMenuView { MessageContextMenuView {
id: memberContextMenuView id: memberContextMenuView
store: root.rootStore store: root.rootStore
isProfile: true
amIChatAdmin: root.rootStore.amIChatAdmin() amIChatAdmin: root.rootStore.amIChatAdmin()
myPublicKey: root.rootStore.myPublicKey() myPublicKey: root.rootStore.myPublicKey()

View File

@ -93,10 +93,11 @@ Item {
delegate: ContactPanel { delegate: ContactPanel {
id: panelDelegate id: panelDelegate
width: ListView.view.width width: ListView.view.width
contactsStore: root.contactsStore contactsStore: root.contactsStore
name: ProfileUtils.displayName(model.localNickname, model.ensName, model.displayName, model.alias) name: ProfileUtils.displayName(model.localNickname, model.ensName, model.displayName, model.alias)
ensVerified: !!model.ensName ensVerified: model.isEnsVerified
publicKey: model.pubKey publicKey: model.pubKey
compressedPk: Utils.getCompressedPk(model.pubKey) compressedPk: Utils.getCompressedPk(model.pubKey)
iconSource: model.icon iconSource: model.icon

View File

@ -17,13 +17,9 @@ import "../stores"
ActivityNotificationMessage { ActivityNotificationMessage {
id: root id: root
readonly property var contactDetails: notification ? contactDetails: notification ? Utils.getContactDetailsAsJson(notification.author, false) : null
Utils.getContactDetailsAsJson(notification.author, false) :
null
messageDetails.messageText: qsTr("Wants to join") messageDetails.messageText: qsTr("Wants to join")
messageDetails.sender.displayName: contactDetails ? contactDetails.displayName : ""
messageDetails.sender.secondaryName: contactDetails ? contactDetails.localNickname : ""
messageDetails.sender.profileImage.name: contactDetails ? contactDetails.displayIcon : "" messageDetails.sender.profileImage.name: contactDetails ? contactDetails.displayIcon : ""
messageDetails.sender.profileImage.assetSettings.isImage: true messageDetails.sender.profileImage.assetSettings.isImage: true
messageDetails.sender.profileImage.pubkey: notification ? notification.author : "" messageDetails.sender.profileImage.pubkey: notification ? notification.author : ""

View File

@ -24,10 +24,10 @@ ActivityNotificationBase {
messageText: notification ? notification.message.messageText : "" messageText: notification ? notification.message.messageText : ""
amISender: false amISender: false
sender.id: contactId sender.id: contactId
sender.displayName: contactDetails ? ProfileUtils.displayName(contactDetails.localNickname, contactDetails.ensVerified ? contactDetails.name : "", sender.displayName: contactDetails ? ProfileUtils.displayName(contactDetails.localNickname, contactDetails.name,
contactDetails.displayName, contactDetails.alias) : "" contactDetails.displayName, contactDetails.alias) : ""
sender.secondaryName: contactDetails && contactDetails.localNickname ? ProfileUtils.displayName("", contactDetails.ensVerified ? contactDetails.name : "", sender.secondaryName: contactDetails && contactDetails.localNickname ?
contactDetails.displayName, contactDetails.alias) : "" ProfileUtils.displayName("", contactDetails.name, contactDetails.displayName, contactDetails.alias) : ""
sender.trustIndicator: contactDetails ? contactDetails.trustStatus : Constants.trustStatus.unknown sender.trustIndicator: contactDetails ? contactDetails.trustStatus : Constants.trustStatus.unknown
sender.isEnsVerified: !!contactDetails && contactDetails.ensVerified sender.isEnsVerified: !!contactDetails && contactDetails.ensVerified
sender.isContact: !!contactDetails && contactDetails.isContact sender.isContact: !!contactDetails && contactDetails.isContact

View File

@ -14,20 +14,19 @@ StatusMemberListItem {
id: root id: root
readonly property string _pubKey: model.pubKey // expose uncompressed pubkey readonly property string _pubKey: model.pubKey // expose uncompressed pubkey
readonly property bool hasEnsName: Utils.isEnsVerified(model.pubKey)
pubKey: hasEnsName ? "" : Utils.getCompressedPk(model.pubKey) pubKey: model.isEnsVerified ? "" : Utils.getCompressedPk(model.pubKey)
nickName: model.localNickname nickName: model.localNickname
userName: ProfileUtils.displayName("", model.ensName, model.displayName, model.alias) userName: ProfileUtils.displayName("", model.ensName, model.displayName, model.alias)
isVerified: model.isVerified isVerified: model.isVerified
isUntrustworthy: model.isUntrustworthy isUntrustworthy: model.isUntrustworthy
isContact: model.isContact isContact: model.isContact
asset.name: model.icon asset.name: model.icon
asset.color: Utils.colorForPubkey(model.pubKey) asset.color: Utils.colorForColorId(model.colorId)
asset.isImage: (asset.name !== "") asset.isImage: (asset.name !== "")
asset.isLetterIdenticon: (asset.name === "") asset.isLetterIdenticon: (asset.name === "")
status: model.onlineStatus status: model.onlineStatus
statusListItemIcon.badge.border.color: sensor.containsMouse ? Theme.palette.baseColor2 : Theme.palette.baseColor4 statusListItemIcon.badge.border.color: sensor.containsMouse ? Theme.palette.baseColor2 : Theme.palette.baseColor4
ringSettings.ringSpecModel: Utils.getColorHashAsJson(model.pubKey, hasEnsName) ringSettings.ringSpecModel: model.colorHash
color: (sensor.containsMouse || highlighted) ? Theme.palette.baseColor2 : "transparent" color: (sensor.containsMouse || highlighted) ? Theme.palette.baseColor2 : "transparent"
} }

View File

@ -83,8 +83,7 @@ Item {
delegate: StatusMemberListItem { delegate: StatusMemberListItem {
width: contactListView.availableWidth width: contactListView.availableWidth
pubKey: model.isEnsVerified ? "" : Utils.getCompressedPk(model.pubKey)
pubKey: Utils.getCompressedPk(model.pubKey)
isContact: model.isContact isContact: model.isContact
status: model.onlineStatus status: model.onlineStatus
height: visible ? implicitHeight : 0 height: visible ? implicitHeight : 0
@ -97,7 +96,7 @@ Item {
asset.width: 40 asset.width: 40
asset.height: 40 asset.height: 40
asset.color: Utils.colorForColorId(model.colorId) asset.color: Utils.colorForColorId(model.colorId)
ringSettings.ringSpecModel: Utils.getColorHashAsJson(model.pubKey, model.ensName) ringSettings.ringSpecModel: model.colorHash
statusListItemIcon.badge.border.color: Theme.palette.baseColor4 statusListItemIcon.badge.border.color: Theme.palette.baseColor4
statusListItemIcon.badge.implicitHeight: 14 // 10 px + 2 px * 2 borders statusListItemIcon.badge.implicitHeight: 14 // 10 px + 2 px * 2 borders
statusListItemIcon.badge.implicitWidth: 14 // 10 px + 2 px * 2 borders statusListItemIcon.badge.implicitWidth: 14 // 10 px + 2 px * 2 borders

View File

@ -46,7 +46,7 @@ Item {
delegate: StatusMemberListItem { delegate: StatusMemberListItem {
width: contactGridView.cellWidth width: contactGridView.cellWidth
pubKey: Utils.getCompressedPk(model.pubKey) pubKey: model.isEnsVerified ? "" : Utils.getCompressedPk(model.pubKey)
isContact: model.isContact isContact: model.isContact
status: model.onlineStatus status: model.onlineStatus
nickName: model.localNickname nickName: model.localNickname
@ -59,7 +59,7 @@ Item {
asset.height: 40 asset.height: 40
color: "transparent" color: "transparent"
asset.color: Utils.colorForColorId(model.colorId) asset.color: Utils.colorForColorId(model.colorId)
ringSettings.ringSpecModel: Utils.getColorHashAsJson(model.pubKey) ringSettings.ringSpecModel: model.colorHash
statusListItemIcon.badge.border.color: Theme.palette.baseColor4 statusListItemIcon.badge.border.color: Theme.palette.baseColor4
statusListItemIcon.badge.implicitHeight: 14 // 10 px + 2 px * 2 borders statusListItemIcon.badge.implicitHeight: 14 // 10 px + 2 px * 2 borders
statusListItemIcon.badge.implicitWidth: 14 // 10 px + 2 px * 2 borders statusListItemIcon.badge.implicitWidth: 14 // 10 px + 2 px * 2 borders

View File

@ -697,6 +697,7 @@ Pane {
Layout.rightMargin: column.anchors.rightMargin Layout.rightMargin: column.anchors.rightMargin
bottomPadding: -4 bottomPadding: -4
StatusTabButton { StatusTabButton {
leftPadding: 0
width: implicitWidth width: implicitWidth
text: qsTr("Communities") text: qsTr("Communities")
} }
@ -709,7 +710,6 @@ Pane {
text: qsTr("Collectibles") text: qsTr("Collectibles")
} }
StatusTabButton { StatusTabButton {
leftPadding: 0
width: implicitWidth width: implicitWidth
text: qsTr("Assets") text: qsTr("Assets")
} }

View File

@ -443,8 +443,7 @@ Loader {
if (!root.pinnedMessage || root.isDiscordMessage) if (!root.pinnedMessage || root.isDiscordMessage)
return "" return ""
const contact = Utils.getContactDetailsAsJson(root.messagePinnedBy, false) const contact = Utils.getContactDetailsAsJson(root.messagePinnedBy, false)
const ensName = contact.ensVerified ? contact.name : "" return ProfileUtils.displayName(contact.localNickname, contact.name, contact.displayName, contact.alias)
return ProfileUtils.displayName(contact.localNickname, ensName, contact.displayName, contact.alias)
} }
isInPinnedPopup: root.isInPinnedPopup isInPinnedPopup: root.isInPinnedPopup
hasExpired: root.isExpired hasExpired: root.isExpired

View File

@ -55,7 +55,7 @@ RowLayout {
sender: root.messageDetails.sender sender: root.messageDetails.sender
amISender: root.messageDetails.amISender amISender: root.messageDetails.amISender
messageOriginInfo: root.messageDetails.messageOriginInfo messageOriginInfo: root.messageDetails.messageOriginInfo
tertiaryDetail: Utils.getElidedCompressedPk(sender.id) tertiaryDetail: sender.isEnsVerified ? "" : Utils.getElidedCompressedPk(sender.id)
timestamp: root.timestamp timestamp: root.timestamp
onClicked: root.openProfilePopup() onClicked: root.openProfilePopup()
} }

View File

@ -436,7 +436,7 @@ QtObject {
function isEnsVerified(publicKey) { function isEnsVerified(publicKey) {
if (publicKey === "" || !isChatKey(publicKey) ) if (publicKey === "" || !isChatKey(publicKey) )
return return
return getContactDetailsAsJson(publicKey, false).ensVerified return mainModuleInst.isEnsVerified(publicKey)
} }
function getEmojiHashAsJson(publicKey) { function getEmojiHashAsJson(publicKey) {