From bd4bb0a56667caa788b7f852006086e4f2e66c52 Mon Sep 17 00:00:00 2001 From: Boris Melnik Date: Mon, 22 May 2023 17:35:03 +0300 Subject: [PATCH] fix(community-permissions): Fixed failed event sending and fix method declaration Fixes: #10736 --- src/app/modules/main/module.nim | 2 +- src/app_service/service/community/service.nim | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/app/modules/main/module.nim b/src/app/modules/main/module.nim index adaba1137c..b4fb40b0a2 100644 --- a/src/app/modules/main/module.nim +++ b/src/app/modules/main/module.nim @@ -1010,7 +1010,7 @@ method onAcceptRequestToJoinLoading*[T](self: Module[T], communityId: string, me if item.id != "": item.updatePendingRequestLoadingState(memberKey, true) -method onAcceptRequestToJoinFailed*[T](self: Module[T], communityId: string, memberKey: string) = +method onAcceptRequestToJoinFailed*[T](self: Module[T], communityId: string, memberKey: string, requestId: string) = let item = self.view.model().getItemById(communityId) if item.id != "": item.updatePendingRequestLoadingState(memberKey, false) diff --git a/src/app_service/service/community/service.nim b/src/app_service/service/community/service.nim index 6c91efbc34..1057bbffcc 100644 --- a/src/app_service/service/community/service.nim +++ b/src/app_service/service/community/service.nim @@ -1388,11 +1388,14 @@ QtObject: error "Error accepting request to join community", msg = e.msg proc onAsyncAcceptRequestToJoinCommunityDone*(self: Service, response: string) {.slot.} = + var communityId: string + var requestId: string + var userKey: string try: let rpcResponseObj = response.parseJson - let communityId = rpcResponseObj{"communityId"}.getStr - let requestId = rpcResponseObj{"requestId"}.getStr - let userKey = self.getUserPubKeyFromPendingRequest(communityId, requestId) + communityId = rpcResponseObj{"communityId"}.getStr + requestId = rpcResponseObj{"requestId"}.getStr + userKey = self.getUserPubKeyFromPendingRequest(communityId, requestId) if rpcResponseObj{"error"}.kind != JNull and rpcResponseObj{"error"}.getStr != "": let errorMessage = rpcResponseObj{"error"}.getStr @@ -1416,7 +1419,7 @@ QtObject: except Exception as e: let errMsg = e.msg error "error accepting request to join: ", errMsg - self.events.emit(SIGNAL_ACCEPT_REQUEST_TO_JOIN_FAILED, Args()) + self.events.emit(SIGNAL_ACCEPT_REQUEST_TO_JOIN_FAILED, CommunityMemberArgs(communityId: communityId, pubKey: userKey, requestId: requestId)) proc asyncLoadCuratedCommunities*(self: Service) = self.events.emit(SIGNAL_CURATED_COMMUNITIES_LOADING, Args())