fix(@desktop/chat): make `join` invite transition to `pending`
User should see `pending` state after he `join`s the community, even if that community does not require explicit admin approval. That's because currently, each member has to be accepted by admin, either automatically or manually. That means, if admin is gone, no one will be ever joined to community, even if this community states it does not require request to join.
This commit is contained in:
parent
d1b3e7af9e
commit
e3363e269a
|
@ -517,6 +517,17 @@ QtObject:
|
|||
return false
|
||||
return self.allCommunities[communityId].canJoin
|
||||
|
||||
proc processRequestsToJoinCommunity(self: Service, responseResult: JsonNode): bool =
|
||||
if responseResult{"requestsToJoinCommunity"} == nil or responseResult{"requestsToJoinCommunity"}.kind == JNull:
|
||||
return false
|
||||
|
||||
for jsonCommunityReqest in responseResult["requestsToJoinCommunity"]:
|
||||
let communityRequest = jsonCommunityReqest.toCommunityMembershipRequestDto()
|
||||
self.myCommunityRequests.add(communityRequest)
|
||||
self.events.emit(SIGNAL_COMMUNITY_MY_REQUEST_ADDED, CommunityRequestArgs(communityRequest: communityRequest))
|
||||
|
||||
return true
|
||||
|
||||
proc joinCommunity*(self: Service, communityId: string): string =
|
||||
result = ""
|
||||
try:
|
||||
|
@ -541,6 +552,9 @@ QtObject:
|
|||
error "error: ", procName="joinCommunity", errDesription = "no 'communitiesSettings' key in response"
|
||||
return
|
||||
|
||||
if not self.processRequestsToJoinCommunity(response.result):
|
||||
error "error: ", procName="joinCommunity", errDesription = "no 'requestsToJoinCommunity' key in response"
|
||||
|
||||
var updatedCommunity = response.result["communities"][0].toCommunityDto()
|
||||
let communitySettings = response.result["communitiesSettings"][0].toCommunitySettingsDto()
|
||||
|
||||
|
@ -570,11 +584,9 @@ QtObject:
|
|||
try:
|
||||
let response = status_go.requestToJoinCommunity(communityId, ensName)
|
||||
|
||||
if response.result{"requestsToJoinCommunity"} != nil and response.result{"requestsToJoinCommunity"}.kind != JNull:
|
||||
for jsonCommunityReqest in response.result["requestsToJoinCommunity"]:
|
||||
let communityRequest = jsonCommunityReqest.toCommunityMembershipRequestDto()
|
||||
self.myCommunityRequests.add(communityRequest)
|
||||
self.events.emit(SIGNAL_COMMUNITY_MY_REQUEST_ADDED, CommunityRequestArgs(communityRequest: communityRequest))
|
||||
if not self.processRequestsToJoinCommunity(response.result):
|
||||
error "error: ", procName="requestToJoinCommunity", errDesription = "no 'requestsToJoinCommunity' key in response"
|
||||
|
||||
except Exception as e:
|
||||
error "Error requesting to join the community", msg = e.msg, communityId, ensName
|
||||
|
||||
|
|
|
@ -99,6 +99,15 @@ Item {
|
|||
border.width: 1
|
||||
|
||||
states: [
|
||||
State {
|
||||
name: "pending"
|
||||
when: d.invitationPending
|
||||
PropertyChanges {
|
||||
target: joinBtn
|
||||
text: qsTr("Pending")
|
||||
enabled: false
|
||||
}
|
||||
},
|
||||
State {
|
||||
name: "requiresEns"
|
||||
when: d.invitedCommunity.ensOnly && !userProfile.ensName
|
||||
|
@ -117,16 +126,6 @@ Item {
|
|||
enabled: false
|
||||
}
|
||||
},
|
||||
State {
|
||||
name: "pending"
|
||||
when: d.invitedCommunity.access === Constants.communityChatOnRequestAccess &&
|
||||
d.invitationPending
|
||||
PropertyChanges {
|
||||
target: joinBtn
|
||||
text: qsTr("Pending")
|
||||
enabled: false
|
||||
}
|
||||
},
|
||||
State {
|
||||
name: "joined"
|
||||
when: (d.invitedCommunity.joined && d.invitedCommunity.isMember) ||
|
||||
|
|
Loading…
Reference in New Issue