diff --git a/src/app/modules/main/module.nim b/src/app/modules/main/module.nim index 91d72edce6..e681ee1608 100644 --- a/src/app/modules/main/module.nim +++ b/src/app/modules/main/module.nim @@ -390,6 +390,12 @@ proc createCommunitySectionItem[T](self: Module[T], communityDetails: CommunityD memberItems = concat(memberItems, pendingMembers, declinedMemberItems, bannedMembers) + # Remove duplicates, this can happen when the requests to join have not updated in time + var finalMembers: Table[string, MemberItem] + for memberItem in memberItems: + if not finalMembers.contains(memberItem.pubKey): + finalMembers[memberItem.pubKey] = memberItem + result = initItem( communityDetails.id, sectionType = SectionType.Community, @@ -417,7 +423,7 @@ proc createCommunitySectionItem[T](self: Module[T], communityDetails: CommunityD communityDetails.permissions.access, communityDetails.permissions.ensOnly, communityDetails.muted, - memberItems, + finalMembers.values.toSeq(), communityDetails.settings.historyArchiveSupportEnabled, communityDetails.adminSettings.pinMessageAllMembersEnabled, communityDetails.encrypted, diff --git a/src/app_service/service/community/service.nim b/src/app_service/service/community/service.nim index 86df15a974..6729a3d184 100644 --- a/src/app_service/service/community/service.nim +++ b/src/app_service/service/community/service.nim @@ -337,6 +337,10 @@ QtObject: self.events.on(SignalType.Message.event) do(e: Args): var receivedData = MessageSignal(e) + # Handling membership requests + if(receivedData.membershipRequests.len > 0): + self.handleCommunitiesRequestsToJoin(receivedData.membershipRequests) + # Handling community updates if (receivedData.communities.len > 0): # Channel added removed is notified in the chats param @@ -345,10 +349,6 @@ QtObject: if (receivedData.communitiesSettings.len > 0): self.handleCommunitiesSettingsUpdates(receivedData.communitiesSettings) - # Handling membership requests - if(receivedData.membershipRequests.len > 0): - self.handleCommunitiesRequestsToJoin(receivedData.membershipRequests) - self.events.on(SignalType.DiscordCategoriesAndChannelsExtracted.event) do(e: Args): var receivedData = DiscordCategoriesAndChannelsExtractedSignal(e) self.events.emit(SIGNAL_DISCORD_CATEGORIES_AND_CHANNELS_EXTRACTED, DiscordCategoriesAndChannelsArgs( @@ -788,12 +788,12 @@ QtObject: # Request was accepted, update the member's airdrop address self.events.emit(SIGNAL_NEW_REQUEST_TO_JOIN_COMMUNITY_ACCEPTED, CommunityRequestArgs(communityRequest: membershipRequest)) - else: - try: - self.updateMembershipRequestToNewState(membershipRequest.communityId, membershipRequest.id, self.communities[membershipRequest.communityId], - requestToJoinState) - except Exception as e: - error "Unknown request", msg = e.msg + + try: + self.updateMembershipRequestToNewState(membershipRequest.communityId, membershipRequest.id, self.communities[membershipRequest.communityId], + requestToJoinState) + except Exception as e: + error "Unknown request", msg = e.msg proc init*(self: Service) = self.doConnect() diff --git a/test/e2e/tests/communities/test_communities_pin_and_unpin_messages.py b/test/e2e/tests/communities/test_communities_pin_and_unpin_messages.py index 79cce8da37..6aab9680b6 100644 --- a/test/e2e/tests/communities/test_communities_pin_and_unpin_messages.py +++ b/test/e2e/tests/communities/test_communities_pin_and_unpin_messages.py @@ -22,7 +22,6 @@ pytestmark = marks 'Edit chat - Remove pinned message (when any member can pin is disabled)') @allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/703510', 'Join community via owner invite') @pytest.mark.case(703255, 703256, 703510) -@pytest.mark.xfail(reason='https://github.com/status-im/status-desktop/issues/16672') def test_join_community_and_pin_unpin_message(multiple_instances): user_one: UserAccount = RandomUser() user_two: UserAccount = RandomUser()