From c20554d987327e931f047402c4c16cde91d05bcc Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Mon, 24 Jan 2022 10:47:20 -0500 Subject: [PATCH] refactor(community): use user model for the community member list Fixes #4471 --- .../chat_content/users/module.nim | 3 +- .../chat_section/chat_content/users/view.nim | 2 +- .../modules/main/communities/controller.nim | 19 ++- .../main/communities/controller_interface.nim | 10 ++ .../models/pending_request_model.nim | 10 +- src/app/modules/main/communities/module.nim | 20 +++- src/app/modules/main/controller.nim | 8 ++ src/app/modules/main/module.nim | 16 ++- .../module_controller_delegate_interface.nim | 5 +- src/app/modules/main/view.nim | 3 + .../modules/shared_models/active_section.nim | 8 ++ src/app/modules/shared_models/member_item.nim | 27 ----- .../modules/shared_models/members_model.nim | 109 ------------------ .../modules/shared_models/section_item.nim | 24 ++-- .../item.nim => shared_models/user_item.nim} | 20 +++- .../user_model.nim} | 18 ++- .../CommunityProfilePopupMembersListPanel.qml | 22 ++-- 17 files changed, 143 insertions(+), 181 deletions(-) delete mode 100644 src/app/modules/shared_models/member_item.nim delete mode 100644 src/app/modules/shared_models/members_model.nim rename src/app/modules/{main/chat_section/chat_content/users/item.nim => shared_models/user_item.nim} (70%) rename src/app/modules/{main/chat_section/chat_content/users/model.nim => shared_models/user_model.nim} (92%) 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 16f7c6c886..403d45da2e 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 @@ -1,7 +1,8 @@ import NimQml import io_interface import ../io_interface as delegate_interface -import view, item, model, controller +import view, controller +import ../../../../shared_models/[user_model, user_item] import ../../../../../global/global_singleton import ../../../../../core/eventemitter import ../../../../../../app_service/service/contacts/service as contact_service diff --git a/src/app/modules/main/chat_section/chat_content/users/view.nim b/src/app/modules/main/chat_section/chat_content/users/view.nim index 3d6b3e9658..2d67815890 100644 --- a/src/app/modules/main/chat_section/chat_content/users/view.nim +++ b/src/app/modules/main/chat_section/chat_content/users/view.nim @@ -1,5 +1,5 @@ import NimQml -import model +import ../../../../shared_models/user_model import io_interface QtObject: diff --git a/src/app/modules/main/communities/controller.nim b/src/app/modules/main/communities/controller.nim index 9d526f9dba..ee2f9d02ea 100644 --- a/src/app/modules/main/communities/controller.nim +++ b/src/app/modules/main/communities/controller.nim @@ -5,6 +5,7 @@ import ./io_interface import ../../../core/signals/types import ../../../core/eventemitter import ../../../../app_service/service/community/service as community_service +import ../../../../app_service/service/contacts/service as contacts_service export controller_interface @@ -13,24 +14,24 @@ type delegate: io_interface.AccessInterface events: EventEmitter communityService: community_service.Service + contactsService: contacts_service.Service proc newController*( delegate: io_interface.AccessInterface, events: EventEmitter, - communityService: community_service.Service + communityService: community_service.Service, + contactsService: contacts_service.Service ): Controller = result = Controller() result.delegate = delegate result.events = events result.communityService = communityService + result.contactsService = contactsService method delete*(self: Controller) = discard method init*(self: Controller) = - let communities = self.communityService.getAllCommunities() - self.delegate.setAllCommunities(communities) - self.events.on(SIGNAL_COMMUNITY_CREATED) do(e:Args): let args = CommunityArgs(e) self.delegate.addCommunity(args.community) @@ -63,6 +64,9 @@ method init*(self: Controller) = let args = CommunityCategoryArgs(e) # self.delegate.communityCategoryDeleted() +method getAllCommunities*(self: Controller): seq[CommunityDto] = + result = self.communityService.getAllCommunities() + method joinCommunity*(self: Controller, communityId: string): string = self.communityService.joinCommunity(communityId) @@ -153,3 +157,10 @@ method removeUserFromCommunity*(self: Controller, communityId: string, pubKeys: method banUserFromCommunity*(self: Controller, communityId: string, pubKey: string) = self.communityService.removeUserFromCommunity(communityId, pubKey) + +method setCommunityMuted*(self: Controller, communityId: string, muted: bool) = + self.communityService.setCommunityMuted(communityId, muted) + +method getContactNameAndImage*(self: Controller, contactId: string): + tuple[name: string, image: string, isIdenticon: bool] = + return self.contactsService.getContactNameAndImage(contactId) \ No newline at end of file diff --git a/src/app/modules/main/communities/controller_interface.nim b/src/app/modules/main/communities/controller_interface.nim index bf264b5137..bf72401b31 100644 --- a/src/app/modules/main/communities/controller_interface.nim +++ b/src/app/modules/main/communities/controller_interface.nim @@ -10,6 +10,9 @@ method delete*(self: AccessInterface) {.base.} = method init*(self: AccessInterface) {.base.} = raise newException(ValueError, "No implementation available") +method getAllCommunities*(self: AccessInterface): seq[CommunityDto] {.base.} = + raise newException(ValueError, "No implementation available") + method joinCommunity*(self: AccessInterface, communityId: string): string {.base.} = raise newException(ValueError, "No implementation available") @@ -49,6 +52,13 @@ method removeUserFromCommunity*(self: AccessInterface, communityId: string, pubK method banUserFromCommunity*(self: AccessInterface, communityId: string, pubKey: string) {.base.} = raise newException(ValueError, "No implementation available") +method setCommunityMuted*(self: AccessInterface, communityId: string, muted: bool) {.base.} = + raise newException(ValueError, "No implementation available") + +method getContactNameAndImage*(self: AccessInterface, contactId: string): + tuple[name: string, image: string, isIdenticon: bool] {.base.} = + raise newException(ValueError, "No implementation available") + type ## Abstract class (concept) which must be implemented by object/s used in this ## module. diff --git a/src/app/modules/main/communities/models/pending_request_model.nim b/src/app/modules/main/communities/models/pending_request_model.nim index 2fee4f658a..12196ea840 100644 --- a/src/app/modules/main/communities/models/pending_request_model.nim +++ b/src/app/modules/main/communities/models/pending_request_model.nim @@ -21,12 +21,18 @@ QtObject: self.items = @[] self.QAbstractListModel.delete - proc newPendingRequestModel*(pendingRequestsToJoin: seq[PendingRequestItem]): PendingRequestModel = + proc newPendingRequestModel*(): PendingRequestModel = new(result, delete) - result.items = pendingRequestsToJoin result.setup proc countChanged(self: PendingRequestModel) {.signal.} + + proc setItems*(self: PendingRequestModel, items: seq[PendingRequestItem]) = + self.beginResetModel() + self.items = items + self.endResetModel() + self.countChanged() + proc getCount(self: PendingRequestModel): int {.slot.} = self.items.len QtProperty[int] count: diff --git a/src/app/modules/main/communities/module.nim b/src/app/modules/main/communities/module.nim index 1e1eb670ec..3ba261610d 100644 --- a/src/app/modules/main/communities/module.nim +++ b/src/app/modules/main/communities/module.nim @@ -4,11 +4,11 @@ import ./io_interface import ../io_interface as delegate_interface import ./view, ./controller import ../../shared_models/section_item -import ../../shared_models/member_item -import ../../shared_models/members_model +import ../../shared_models/[user_item, user_model] import ../../../global/global_singleton import ../../../core/eventemitter import ../../../../app_service/service/community/service as community_service +import ../../../../app_service/service/contacts/service as contacts_service export io_interface @@ -20,10 +20,14 @@ type viewVariant: QVariant moduleLoaded: bool +# Forward declaration +method setAllCommunities*(self: Module, communities: seq[CommunityDto]) + proc newModule*( delegate: delegate_interface.AccessInterface, events: EventEmitter, - communityService: community_service.Service + communityService: community_service.Service, + contactsService: contacts_service.Service ): Module = result = Module() result.delegate = delegate @@ -32,7 +36,8 @@ proc newModule*( result.controller = controller.newController( result, events, - communityService + communityService, + contactsService ) result.moduleLoaded = false @@ -51,6 +56,9 @@ method isLoaded*(self: Module): bool = method viewDidLoad*(self: Module) = self.moduleLoaded = true + + self.setAllCommunities(self.controller.getAllCommunities()) + self.delegate.communitiesModuleDidLoad() method getCommunityItem(self: Module, c: CommunityDto): SectionItem = @@ -74,7 +82,9 @@ method getCommunityItem(self: Module, c: CommunityDto): SectionItem = c.isMember, c.permissions.access, c.permissions.ensOnly, - c.members.map(x => member_item.initItem(x.id, x.roles)) + c.members.map(proc(member: Member): user_item.Item = + let (name, image, isIdenticon) = self.controller.getContactNameAndImage(member.id) + result = user_item.initItem(member.id, name, OnlineStatus.Offline, image, isIdenticon)) ) method setAllCommunities*(self: Module, communities: seq[CommunityDto]) = diff --git a/src/app/modules/main/controller.nim b/src/app/modules/main/controller.nim index f73b9ee783..b918ba5105 100644 --- a/src/app/modules/main/controller.nim +++ b/src/app/modules/main/controller.nim @@ -126,6 +126,14 @@ method init*(self: Controller) = var args = ResolvedContactArgs(e) self.delegate.resolvedENS(args.pubkey, args.address, args.uuid) + self.events.on(SIGNAL_CONTACT_UPDATED) do(e: Args): + var args = ContactArgs(e) + self.delegate.contactUpdated(args.contactId) + + self.events.on(SIGNAL_CONTACT_NICKNAME_CHANGED) do(e: Args): + var args = ContactArgs(e) + self.delegate.contactUpdated(args.contactId) + method getJoinedCommunities*(self: Controller): seq[CommunityDto] = return self.communityService.getJoinedCommunities() diff --git a/src/app/modules/main/module.nim b/src/app/modules/main/module.nim index 3ef342f7fa..5d18cfd60a 100644 --- a/src/app/modules/main/module.nim +++ b/src/app/modules/main/module.nim @@ -1,8 +1,8 @@ import NimQml, tables, json, sugar, sequtils -import io_interface, view, controller, ../shared_models/section_item,../shared_models/section_model -import ../shared_models/member_item, ../shared_models/members_model +import io_interface, view, controller import ./communities/models/[pending_request_item, pending_request_model] +import ../shared_models/[user_item, user_model, section_item, section_model, active_section] import ../../global/app_sections_config as conf import ../../global/app_signals import ../../global/global_singleton @@ -134,7 +134,7 @@ proc newModule*[T]( result.stickersModule = stickers_module.newModule(result, events, stickersService) result.activityCenterModule = activity_center_module.newModule(result, events, activityCenterService, contactsService, messageService) - result.communitiesModule = communities_module.newModule(result, events, communityService) + result.communitiesModule = communities_module.newModule(result, events, communityService, contactsService) result.appSearchModule = app_search_module.newModule(result, events, contactsService, chatService, communityService, messageService) result.nodeSectionModule = node_section_module.newModule(result, events, settingsService, nodeService, nodeConfigurationService) @@ -180,7 +180,9 @@ proc createCommunityItem[T](self: Module[T], c: CommunityDto): SectionItem = c.isMember, c.permissions.access, c.permissions.ensOnly, - c.members.map(x => member_item.initItem(x.id, x.roles)), + c.members.map(proc(member: Member): user_item.Item = + let (name, image, isIdenticon) = self.controller.getContactNameAndImage(member.id) + result = user_item.initItem(member.id, name, OnlineStatus.Offline, image, isIdenticon)), c.pendingRequestsToJoin.map(x => pending_request_item.initItem( x.id, x.publicKey, @@ -585,4 +587,8 @@ method resolveENS*[T](self: Module[T], ensName: string, uuid: string) = self.controller.resolveENS(ensName, uuid) method resolvedENS*[T](self: Module[T], publicKey: string, address: string, uuid: string) = - self.view.emitResolvedENSSignal(publicKey, address, uuid) \ No newline at end of file + self.view.emitResolvedENSSignal(publicKey, address, uuid) + +method contactUpdated*[T](self: Module[T], publicKey: string) = + let (name, image, isIdenticon) = self.controller.getContactNameAndImage(publicKey) + self.view.activeSection().updateMember(publicKey, name, image, isIdenticon) \ No newline at end of file diff --git a/src/app/modules/main/private_interfaces/module_controller_delegate_interface.nim b/src/app/modules/main/private_interfaces/module_controller_delegate_interface.nim index c34e27ab01..8661361bbf 100644 --- a/src/app/modules/main/private_interfaces/module_controller_delegate_interface.nim +++ b/src/app/modules/main/private_interfaces/module_controller_delegate_interface.nim @@ -31,4 +31,7 @@ method communityLeft*(self: AccessInterface, communityId: string) {.base.} = raise newException(ValueError, "No implementation available") method resolvedENS*(self: AccessInterface, publicKey: string, address: string, uuid: string) {.base.} = - raise newException(ValueError, "No implementation available") \ No newline at end of file + raise newException(ValueError, "No implementation available") + +method contactUpdated*(self: AccessInterface, publicKey: string) {.base.} = + raise newException(ValueError, "No implementation available") diff --git a/src/app/modules/main/view.nim b/src/app/modules/main/view.nim index bb2fad1f8c..36667ef79d 100644 --- a/src/app/modules/main/view.nim +++ b/src/app/modules/main/view.nim @@ -75,6 +75,9 @@ QtObject: proc emitStoringPasswordSuccess*(self: View) = self.storingPasswordSuccess() + proc activeSection*(self: View): ActiveSection = + return self.activeSection + proc getActiveSection(self: View): QVariant {.slot.} = return self.activeSectionVariant diff --git a/src/app/modules/shared_models/active_section.nim b/src/app/modules/shared_models/active_section.nim index bc294568c2..d309cb6ca6 100644 --- a/src/app/modules/shared_models/active_section.nim +++ b/src/app/modules/shared_models/active_section.nim @@ -132,6 +132,14 @@ QtObject: proc hasMember(self: ActiveSection, pubkey: string): bool {.slot.} = return self.item.hasMember(pubkey) + proc updateMember*( + self: ActiveSection, + pubkey: string, + name: string, + image: string, + isIdenticon: bool) = + self.item.updateMember(pubkey, name, image, isIdenticon) + proc pendingRequestsToJoin(self: ActiveSection): QVariant {.slot.} = if (self.item.id == ""): # FIXME (Jo) I don't know why but the Item is sometimes empty and doing anything here crashes the app diff --git a/src/app/modules/shared_models/member_item.nim b/src/app/modules/shared_models/member_item.nim deleted file mode 100644 index acaeb8b0fc..0000000000 --- a/src/app/modules/shared_models/member_item.nim +++ /dev/null @@ -1,27 +0,0 @@ -import strformat - -type - MemberItem* = ref object - id: string - roles*: seq[int] - -proc initItem*( - id: string, - roles: seq[int] - ): MemberItem = - result = MemberItem() - result.id = id - result.roles = roles - -proc `$`*(self: MemberItem): string = - result = fmt"""MemberItem( - id: {self.id}, - roles: {$self.roles} - ]""" - - -proc id*(self: MemberItem): string {.inline.} = - self.id - -proc roles*(self: MemberItem): seq[int] {.inline.} = - self.roles diff --git a/src/app/modules/shared_models/members_model.nim b/src/app/modules/shared_models/members_model.nim deleted file mode 100644 index 2d59300c26..0000000000 --- a/src/app/modules/shared_models/members_model.nim +++ /dev/null @@ -1,109 +0,0 @@ -import NimQml, Tables, strformat -import ./member_item -import ../../global/global_singleton - -type - MembersRoles {.pure.} = enum - PubKey = UserRole + 1 - # LastSeen = UserRole, - # StatusType = UserRole, - # Online = UserRole, - # SortKey = UserRole - -QtObject: - type - MembersModel* = ref object of QAbstractListModel - members*: seq[MemberItem] - - proc setup(self: MembersModel) = self.QAbstractListModel.setup - - proc delete(self: MembersModel) = - self.QAbstractListModel.delete - - proc newMembersModel*(members: seq[MemberItem]): MembersModel = - new(result, delete) - result.members = members - result.setup() - - proc `$`*(self: MembersModel): string = - for i in 0 ..< self.members.len: - result &= fmt"""MembersModel: - [{i}]:({$self.members[i]}) - """ - - proc getIndexFromPubKey*(self: MembersModel, pubKey: string): int = - var i = 0 - for member in self.members: - if (member.id == pubKey): - return i - i = i + 1 - return -1 - - proc hasMember*(self: MembersModel, pubkey: string): bool = - for member in self.members: - if (member.id == pubkey): - return true - return false - - proc removeMember*(self: MembersModel, pubKey: string) = - let memberIndex = self.getIndexFromPubKey(pubKey) - if (memberIndex == -1): - return - self.beginRemoveRows(newQModelIndex(), memberIndex, memberIndex) - self.members.delete(memberIndex) - self.endRemoveRows() - - proc countChanged*(self: MembersModel) {.signal.} - proc count*(self: MembersModel): int {.slot.} = - self.members.len - - QtProperty[int] count: - read = count - notify = countChanged - - method rowCount(self: MembersModel, index: QModelIndex = nil): int = - self.members.len - - # proc memberStatus(self: MembersModel, pk: string): int = - # if self.membersStatus.hasKey(pk): - # result = self.membersStatus[pk].statusType.int - - # proc isOnline(self: MembersModel, pk: string): bool = - # if self.myPubKey == pk: - # return true - # if self.membersStatus.hasKey(pk): - # result = self.membersStatus[pk].statusType.int == StatusUpdateType.Online.int - - # proc sortKey(self: MembersModel, pk: string): string = - # let name = self.userName(pk, self.alias(pk)) - # if self.isOnline(pk): - # return "A" & name - # return "B" & name - - method data(self: MembersModel, index: QModelIndex, role: int): QVariant = - if not index.isValid: - return - if index.row < 0 or index.row >= self.members.len: - return - - let member = self.members[index.row] - let memberRole = role.MembersRoles - case memberRole: - of MembersRoles.PubKey: result = newQVariant(member.id) - # of MembersRoles.LastSeen: result = newQVariant(self.memberLastSeen(member.id)) - # of MembersRoles.StatusType: result = newQVariant(self.memberStatus(member.id)) - # of MembersRoles.Online: result = newQVariant(self.isOnline(member.id)) - # of MembersRoles.SortKey: result = newQVariant(self.sortKey(member.id)) - - method roleNames(self: MembersModel): Table[int, string] = - { - MembersRoles.PubKey.int:"pubKey" - # MembersRoles.LastSeen.int:"lastSeen", - # MembersRoles.StatusType.int:"statusType", - # MembersRoles.Online.int:"online", - # MembersRoles.SortKey.int:"sortKey" - }.toTable - - # proc triggerUpdate*(self: MembersModel) = - # self.beginResetModel() - # self.endResetModel() diff --git a/src/app/modules/shared_models/section_item.nim b/src/app/modules/shared_models/section_item.nim index c8ed420812..9a959872c2 100644 --- a/src/app/modules/shared_models/section_item.nim +++ b/src/app/modules/shared_models/section_item.nim @@ -1,5 +1,5 @@ import strformat -import ./members_model, ./member_item +import ./user_model, ./user_item import ../main/communities/models/[pending_request_item, pending_request_model] type @@ -33,7 +33,7 @@ type canRequestAccess: bool access: int ensOnly: bool - membersModel: MembersModel + membersModel: user_model.Model pendingRequestsToJoinModel: PendingRequestModel proc initItem*( @@ -56,7 +56,7 @@ proc initItem*( isMember = false, access: int = 0, ensOnly = false, - members: seq[MemberItem] = @[], + members: seq[user_item.Item] = @[], pendingRequestsToJoin: seq[PendingRequestItem] = @[] ): SectionItem = result.id = id @@ -78,8 +78,10 @@ proc initItem*( result.isMember = isMember result.access = access result.ensOnly = ensOnly - result.membersModel = newMembersModel(members) - result.pendingRequestsToJoinModel = newPendingRequestModel(pendingRequestsToJoin) + result.membersModel = newModel() + result.membersModel.setItems(members) + result.pendingRequestsToJoinModel = newPendingRequestModel() + result.pendingRequestsToJoinModel.setItems(pendingRequestsToJoin) proc isEmpty*(self: SectionItem): bool = return self.id.len == 0 @@ -177,11 +179,19 @@ proc access*(self: SectionItem): int {.inline.} = proc ensOnly*(self: SectionItem): bool {.inline.} = self.ensOnly -proc members*(self: SectionItem): MembersModel {.inline.} = +proc members*(self: SectionItem): user_model.Model {.inline.} = self.membersModel proc hasMember*(self: SectionItem, pubkey: string): bool = - self.membersModel.hasMember(pubkey) + self.membersModel.isContactWithIdAdded(pubkey) + +proc updateMember*( + self: SectionItem, + pubkey: string, + name: string, + image: string, + isIdenticon: bool) = + self.membersModel.updateItem(pubkey, name, image, isIdenticon) proc pendingRequestsToJoin*(self: SectionItem): PendingRequestModel {.inline.} = self.pendingRequestsToJoinModel \ No newline at end of file diff --git a/src/app/modules/main/chat_section/chat_content/users/item.nim b/src/app/modules/shared_models/user_item.nim similarity index 70% rename from src/app/modules/main/chat_section/chat_content/users/item.nim rename to src/app/modules/shared_models/user_item.nim index f9d411040b..25913bc62b 100644 --- a/src/app/modules/main/chat_section/chat_content/users/item.nim +++ b/src/app/modules/shared_models/user_item.nim @@ -1,3 +1,5 @@ +import strformat + type OnlineStatus* {.pure.} = enum Offline = 0 @@ -6,6 +8,7 @@ type Idle Invisible +# TODO add role when it is needed type Item* = ref object id: string @@ -14,7 +17,13 @@ type icon: string isIdenticon: bool -proc initItem*(id: string, name: string, onlineStatus: OnlineStatus, icon: string, isidenticon: bool): Item = +proc initItem*( + id: string, + name: string, + onlineStatus: OnlineStatus, + icon: string, + isidenticon: bool + ): Item = result = Item() result.id = id result.name = name @@ -22,6 +31,15 @@ proc initItem*(id: string, name: string, onlineStatus: OnlineStatus, icon: strin result.icon = icon result.isIdenticon = isidenticon +proc `$`*(self: Item): string = + result = fmt"""User Item( + id: {self.id}, + name: {self.name}, + onlineStatus: {$self.onlineStatus.int}, + icon: {self.icon}, + isIdenticon: {$self.isIdenticon} + ]""" + proc id*(self: Item): string {.inline.} = self.id diff --git a/src/app/modules/main/chat_section/chat_content/users/model.nim b/src/app/modules/shared_models/user_model.nim similarity index 92% rename from src/app/modules/main/chat_section/chat_content/users/model.nim rename to src/app/modules/shared_models/user_model.nim index bc91e16d44..b825fdad3d 100644 --- a/src/app/modules/main/chat_section/chat_content/users/model.nim +++ b/src/app/modules/shared_models/user_model.nim @@ -1,6 +1,6 @@ -import NimQml, Tables +import NimQml, Tables, strformat -import item +import user_item type ModelRole {.pure.} = enum @@ -27,6 +27,18 @@ QtObject: result.setup proc countChanged(self: Model) {.signal.} + + proc setItems*(self: Model, items: seq[Item]) = + self.beginResetModel() + self.items = items + self.endResetModel() + self.countChanged() + + proc `$`*(self: Model): string = + for i in 0 ..< self.items.len: + result &= fmt"""User Model: + [{i}]:({$self.items[i]}) + """ proc getCount(self: Model): int {.slot.} = self.items.len QtProperty[int] count: @@ -158,4 +170,4 @@ QtObject: if(ind == -1): return - self.removeItemWithIndex(ind) \ No newline at end of file + self.removeItemWithIndex(ind) diff --git a/ui/app/AppLayouts/Chat/panels/communities/CommunityProfilePopupMembersListPanel.qml b/ui/app/AppLayouts/Chat/panels/communities/CommunityProfilePopupMembersListPanel.qml index 7a4dbac066..3068f3097b 100644 --- a/ui/app/AppLayouts/Chat/panels/communities/CommunityProfilePopupMembersListPanel.qml +++ b/ui/app/AppLayouts/Chat/panels/communities/CommunityProfilePopupMembersListPanel.qml @@ -127,27 +127,19 @@ Item { id: memberList model: root.community.members delegate: StatusListItem { - id: memberItem - property var contactDetail: Utils.getContactDetailsAsJson(model.pubKey) - property string identicon: contactDetail.identicon || root.store.generateIdenticon(model.pubKey) - property string username: contactDetail.name || root.store.generateAlias(model.pubKey) - property string nickname: contactDetail.localNickname || "" - property string profileImage: Global.getProfileImage(model.pubKey) || "" - visible: !!!memberSearch.input.text || - contactDetail.name.toLowerCase().includes(memberSearch.input.text.toLowerCase()) || - nickname.toLowerCase().includes(memberSearch.input.text.toLowerCase()) + model.name.toLowerCase().includes(memberSearch.input.text.toLowerCase()) anchors.horizontalCenter: parent.horizontalCenter - image.isIdenticon: !profileImage - image.source: profileImage || identicon + image.isIdenticon: model.isIdenticon + image.source: model.icon title: { if (menuButton.visible) { - return !username.endsWith(".eth") && !!nickname ? - nickname : Utils.removeStatusEns(username) + return !model.name.endsWith(".eth") ? + model.name : Utils.removeStatusEns(model.name) } //% "You" return qsTrId("You") @@ -158,7 +150,7 @@ Item { id: menuButton width: 32 height: 32 - visible: model.pubKey.toLowerCase() !== userProfile.pubKey.toLowerCase() + visible: model.id.toLowerCase() !== userProfile.pubKey.toLowerCase() icon.name: "more" type: StatusFlatRoundButton.Type.Secondary onClicked: { @@ -178,7 +170,7 @@ Item { //% "View Profile" text: qsTrId("view-profile") icon.name: "channel" - onTriggered: Global.openProfilePopup(model.pubKey) + onTriggered: Global.openProfilePopup(model.id) } StatusMenuSeparator {