Skip to content

Commit 6c31a2a

Browse files
committed
IOS-5239 Do not show members management controls if used does not have permissions
1 parent 8f55bf1 commit 6c31a2a

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

Anytype/Sources/PresentationLayer/Modules/NewSpaceShare/NewSpaceShareViewModel.swift

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,10 @@ final class NewSpaceShareViewModel: ObservableObject {
105105
canChangeInvite = participantSpaceView.permissions.canEditPermissions && participantSpaceView.permissions.canDeleteLink
106106

107107
updateUpgradeViewState()
108-
109-
rows = participants.map { participant in
108+
109+
let filteredParticipants = participantSpaceView.permissions.canEditPermissions ? participants : participants.filter { $0.status == .active }
110+
111+
rows = filteredParticipants.map { participant in
110112
let isYou = workspaceInfo.profileObjectID == participant.identityProfileLink
111113
return SpaceShareParticipantViewModel(
112114
id: participant.id,
@@ -157,6 +159,7 @@ final class NewSpaceShareViewModel: ObservableObject {
157159
}
158160

159161
private func participantContextActions(_ participant: Participant) -> [SpaceShareParticipantViewModel.ContextAction] {
162+
guard let participantSpaceView, participantSpaceView.permissions.canEditPermissions else { return [] }
160163
guard participant.permission != .owner else { return [] }
161164
switch participant.status {
162165
case .active:
@@ -199,7 +202,7 @@ final class NewSpaceShareViewModel: ObservableObject {
199202
}
200203
)] : []
201204
case .removing:
202-
return [
205+
return canApproveRequests ? [
203206
SpaceShareParticipantViewModel.ContextAction(
204207
title: Loc.SpaceShare.Action.approve,
205208
isSelected: false,
@@ -210,7 +213,7 @@ final class NewSpaceShareViewModel: ObservableObject {
210213
try await self?.workspaceService.leaveApprove(spaceId: participant.spaceId, identity: participant.identity)
211214
self?.toastBarData = ToastBarData(Loc.SpaceShare.Approve.toast(participant.title))
212215
}
213-
)]
216+
)] : []
214217
case .removed, .declined, .canceled, .UNRECOGNIZED(_):
215218
return []
216219
}

0 commit comments

Comments
 (0)