fix(requests): fix member requests not showing in list (#16604)
Fixes #16600 There was no update to the model when we get a signal that a membership request is received. We also didn't send an event when one is canceled.
This commit is contained in:
parent
52f59bc60b
commit
3793405843
|
@ -410,7 +410,7 @@ proc init*(self: Controller) =
|
|||
self.delegate.updateRequestToJoinState(RequestToJoinState.Requested)
|
||||
|
||||
self.events.on(SIGNAL_REQUEST_TO_JOIN_COMMUNITY_CANCELED) do(e:Args):
|
||||
let args = community_service.CommunityIdArgs(e)
|
||||
let args = community_service.CanceledCommunityRequestArgs(e)
|
||||
if args.communityId == self.sectionId:
|
||||
self.delegate.updateRequestToJoinState(RequestToJoinState.None)
|
||||
|
||||
|
|
|
@ -309,6 +309,10 @@ proc init*(self: Controller) =
|
|||
var args = CommunityRequestArgs(e)
|
||||
self.delegate.newCommunityMembershipRequestReceived(args.communityRequest)
|
||||
|
||||
self.events.on(SIGNAL_REQUEST_TO_JOIN_COMMUNITY_CANCELED) do(e:Args):
|
||||
let args = community_service.CanceledCommunityRequestArgs(e)
|
||||
self.delegate.communityMembershipRequestCanceled(args.communityId, args.requestId, args.pubKey)
|
||||
|
||||
self.events.on(SIGNAL_NEW_REQUEST_TO_JOIN_COMMUNITY_ACCEPTED) do(e: Args):
|
||||
var args = CommunityRequestArgs(e)
|
||||
self.delegate.communityMemberRevealedAccountsAdded(args.communityRequest)
|
||||
|
|
|
@ -219,6 +219,9 @@ method newCommunityMembershipRequestReceived*(self: AccessInterface, membershipR
|
|||
{.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method communityMembershipRequestCanceled*(self: AccessInterface, communityId: string, requestId: string, pubKey: string) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method meMentionedCountChanged*(self: AccessInterface, allMentions: int) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
|
|
|
@ -1369,6 +1369,16 @@ method newCommunityMembershipRequestReceived*[T](self: Module[T], membershipRequ
|
|||
singletonInstance.globalEvents.newCommunityMembershipRequestNotification("New membership request",
|
||||
fmt "{contactName} asks to join {community.name}", community.id)
|
||||
|
||||
self.view.model().addPendingMember(membershipRequest.communityId, self.createMemberItem(
|
||||
membershipRequest.publicKey,
|
||||
membershipRequest.id,
|
||||
MembershipRequestState(membershipRequest.state),
|
||||
MemberRole.None,
|
||||
))
|
||||
|
||||
method communityMembershipRequestCanceled*[T](self: Module[T], communityId: string, requestId: string, pubKey: string) =
|
||||
self.view.model().removePendingMember(communityId, pubKey)
|
||||
|
||||
method meMentionedCountChanged*[T](self: Module[T], allMentions: int) =
|
||||
singletonInstance.globalEvents.meMentionedIconBadgeNotification(allMentions)
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ import NimQml, Tables, strutils, stew/shims/strformat
|
|||
|
||||
import json
|
||||
|
||||
import section_item, member_model
|
||||
import section_item, member_model, member_item
|
||||
import ../main/communities/tokens/models/[token_item, token_model]
|
||||
|
||||
type
|
||||
|
@ -482,3 +482,15 @@ QtObject:
|
|||
return
|
||||
|
||||
self.items[index].communityTokens.setItems(communityTokensItems)
|
||||
|
||||
proc addPendingMember*(self: SectionModel, communityId: string, memberItem: MemberItem) =
|
||||
let i = self.getItemIndex(communityId)
|
||||
if i == -1:
|
||||
return
|
||||
self.items[i].pendingMemberRequests.addItem(memberItem)
|
||||
|
||||
proc removePendingMember*(self: SectionModel, communityId: string, memberId: string) =
|
||||
let i = self.getItemIndex(communityId)
|
||||
if i == -1:
|
||||
return
|
||||
self.items[i].pendingMemberRequests.removeItemById(memberId)
|
||||
|
|
|
@ -55,6 +55,11 @@ type
|
|||
CommunityRequestArgs* = ref object of Args
|
||||
communityRequest*: CommunityMembershipRequestDto
|
||||
|
||||
CanceledCommunityRequestArgs* = ref object of Args
|
||||
communityId*: string
|
||||
requestId*: string
|
||||
pubKey*: string
|
||||
|
||||
CommunityRequestFailedArgs* = ref object of Args
|
||||
communityId*: string
|
||||
error*: string
|
||||
|
@ -1976,6 +1981,14 @@ QtObject:
|
|||
# If the state is now declined, add to the declined requests
|
||||
if newState == RequestToJoinType.Declined:
|
||||
community.declinedRequestsToJoin.add(community.pendingRequestsToJoin[indexPending])
|
||||
elif newState == RequestToJoinType.Canceled:
|
||||
self.events.emit(SIGNAL_REQUEST_TO_JOIN_COMMUNITY_CANCELED,
|
||||
CanceledCommunityRequestArgs(
|
||||
communityId: communityId,
|
||||
requestId: requestId,
|
||||
pubKey: community.pendingRequestsToJoin[indexPending].publicKey,
|
||||
)
|
||||
)
|
||||
|
||||
# If the state is no longer pending, delete the request
|
||||
community.pendingRequestsToJoin.delete(indexPending)
|
||||
|
@ -2013,9 +2026,15 @@ QtObject:
|
|||
error "error while cancel membership request ", msg
|
||||
return
|
||||
|
||||
self.events.emit(SIGNAL_REQUEST_TO_JOIN_COMMUNITY_CANCELED,
|
||||
CanceledCommunityRequestArgs(
|
||||
communityId: communityId,
|
||||
requestId: myPendingRequest.id,
|
||||
pubKey: community.pendingRequestsToJoin[i].publicKey,
|
||||
)
|
||||
)
|
||||
community.pendingRequestsToJoin.delete(i)
|
||||
self.communities[communityId] = community
|
||||
self.events.emit(SIGNAL_REQUEST_TO_JOIN_COMMUNITY_CANCELED, CommunityIdArgs(communityId: communityId))
|
||||
checkAndEmitACNotificationsFromResponse(self.events, response.result{"activityCenterNotifications"})
|
||||
return
|
||||
|
||||
|
|
Loading…
Reference in New Issue