From 8ae050b642533cf7c4d089219277b3626fe67a16 Mon Sep 17 00:00:00 2001 From: Andrei Smirnov Date: Mon, 30 Aug 2021 19:09:33 +0300 Subject: [PATCH] fix(@desktop/communities): changing contact nickname must be reflected in users list --- src/app/chat/views/communities.nim | 2 +- src/app/chat/views/community_item.nim | 2 +- src/app/chat/views/community_members_list.nim | 18 +++++------------- .../Chat/components/NicknamePopup.qml | 3 +++ 4 files changed, 10 insertions(+), 15 deletions(-) diff --git a/src/app/chat/views/communities.nim b/src/app/chat/views/communities.nim index ad6395dabb..b5f8f24052 100644 --- a/src/app/chat/views/communities.nim +++ b/src/app/chat/views/communities.nim @@ -75,7 +75,7 @@ QtObject: proc updateMemberVisibility*(self: CommunitiesView, statusUpdate: StatusUpdate) = self.joinedCommunityList.updateMemberVisibility(statusUpdate) self.activeCommunity.setCommunityItem(self.joinedCommunityList.getCommunityById(self.activeCommunity.communityItem.id)) - self.activeCommunity.triggerMemberUpdate() + self.activeCommunity.triggerMembersUpdate() proc populateChats(self: CommunitiesView, communities: var seq[Community]): seq[Community] = result = @[] diff --git a/src/app/chat/views/community_item.nim b/src/app/chat/views/community_item.nim index 253e433085..b1fc79a187 100644 --- a/src/app/chat/views/community_item.nim +++ b/src/app/chat/views/community_item.nim @@ -194,7 +194,7 @@ QtObject: proc getMembers*(self: CommunityItemView): QVariant {.slot.} = result = newQVariant(self.members) - proc triggerMemberUpdate*(self: CommunityItemView) = + proc triggerMembersUpdate*(self: CommunityItemView) {.slot.} = self.members.triggerUpdate() proc memberLastSeen*(self: CommunityItemView, pubKey: string): string {.slot.} = diff --git a/src/app/chat/views/community_members_list.nim b/src/app/chat/views/community_members_list.nim index bfe70e173c..2765b1a668 100644 --- a/src/app/chat/views/community_members_list.nim +++ b/src/app/chat/views/community_members_list.nim @@ -56,7 +56,10 @@ QtObject: proc userName(self: CommunityMembersView, pk: string, alias: string): string = if self.status.chat.contacts.hasKey(pk): - result = ens.userNameOrAlias(self.status.chat.contacts[pk]) + if self.status.chat.contacts[pk].localNickname != "": + result = self.status.chat.contacts[pk].localNickname + else: + result = ens.userNameOrAlias(self.status.chat.contacts[pk]) else: result = alias @@ -114,17 +117,6 @@ QtObject: of CommunityMembersRoles.StatusType: result = newQVariant(self.memberStatus(communityMemberPubkey)) of CommunityMembersRoles.Online: result = newQVariant(self.isOnline(communityMemberPubkey)) of CommunityMembersRoles.SortKey: result = newQVariant(self.sortKey(communityMemberPubkey)) - - proc rowData(self: CommunityMembersView, index: int, column: string): string {.slot.} = - if (index >= self.community.members.len): - return - let communityMemberPubkey = self.community.members[index] - case column: - of "alias": result = self.alias(communityMemberPubkey) - of "address": result = communityMemberPubkey - of "identicon": result = self.identicon(communityMemberPubkey) - of "localNickname": result = self.localNickname(communityMemberPubkey) - of "ensName": result = self.userName(communityMemberPubkey, self.alias(communityMemberPubkey)) method roleNames(self: CommunityMembersView): Table[int, string] = { @@ -139,4 +131,4 @@ QtObject: proc triggerUpdate*(self: CommunityMembersView) = self.beginResetModel() - self.endResetModel() \ No newline at end of file + self.endResetModel() diff --git a/ui/app/AppLayouts/Chat/components/NicknamePopup.qml b/ui/app/AppLayouts/Chat/components/NicknamePopup.qml index 4c2cb44a97..a626a9e9fe 100644 --- a/ui/app/AppLayouts/Chat/components/NicknamePopup.qml +++ b/ui/app/AppLayouts/Chat/components/NicknamePopup.qml @@ -117,6 +117,9 @@ ModalPopup { popup.changeNickname(nicknameInput.textField.text) profileModel.contacts.changeContactNickname(fromAuthor, nicknameInput.textField.text) popup.close() + if (!!chatsModel.communities.activeCommunity) { + chatsModel.communities.activeCommunity.triggerMembersUpdate() + } } } }