feature(security&privacy): make spaceSelection part of the state
This commit is contained in:
parent
6a4ab9ba16
commit
cdc3cdc5f1
3 changed files with 14 additions and 7 deletions
|
|
@ -126,6 +126,12 @@ class SecurityAndPrivacyPresenter(
|
|||
value = (joinedParentSpaces + nonParentJoinedSpaces).toImmutableSet()
|
||||
}
|
||||
|
||||
val spaceSelection by remember {
|
||||
derivedStateOf {
|
||||
getSpaceSelection(selectableJoinedSpaces, savedSettings.roomAccess)
|
||||
}
|
||||
}
|
||||
|
||||
var showEnableEncryptionConfirmation by remember(savedSettings.isEncrypted) { mutableStateOf(false) }
|
||||
val permissions by room.permissionsAsState(SecurityAndPrivacyPermissions.DEFAULT) { perms ->
|
||||
perms.securityAndPrivacyPermissions()
|
||||
|
|
@ -183,8 +189,7 @@ class SecurityAndPrivacyPresenter(
|
|||
}
|
||||
SecurityAndPrivacyEvent.ManageAuthorizedSpaces -> navigator.openManageAuthorizedSpaces()
|
||||
SecurityAndPrivacyEvent.SelectSpaceMemberAccess -> handleSpaceMemberAccessSelection(
|
||||
selectableJoinedSpaces = selectableJoinedSpaces,
|
||||
savedAccess = savedSettings.roomAccess,
|
||||
spaceSelection = spaceSelection,
|
||||
editedAccess = editedRoomAccess,
|
||||
)
|
||||
}
|
||||
|
|
@ -206,6 +211,7 @@ class SecurityAndPrivacyPresenter(
|
|||
permissions = permissions,
|
||||
isSpace = roomInfo.isSpace,
|
||||
selectableJoinedSpaces = selectableJoinedSpaces,
|
||||
spaceSelection = spaceSelection,
|
||||
eventSink = ::handleEvent,
|
||||
)
|
||||
|
||||
|
|
@ -230,15 +236,13 @@ class SecurityAndPrivacyPresenter(
|
|||
}
|
||||
|
||||
private fun handleSpaceMemberAccessSelection(
|
||||
selectableJoinedSpaces: Set<SpaceRoom>,
|
||||
savedAccess: SecurityAndPrivacyRoomAccess,
|
||||
spaceSelection: SpaceSelection,
|
||||
editedAccess: MutableState<SecurityAndPrivacyRoomAccess>,
|
||||
) {
|
||||
if(editedAccess.value is SecurityAndPrivacyRoomAccess.SpaceMember) {
|
||||
if (editedAccess.value is SecurityAndPrivacyRoomAccess.SpaceMember) {
|
||||
return
|
||||
}
|
||||
val spaceSelection = getSpaceSelection(selectableJoinedSpaces, savedAccess)
|
||||
when(spaceSelection){
|
||||
when (spaceSelection) {
|
||||
is SpaceSelection.None -> Unit
|
||||
is SpaceSelection.Multiple -> navigator.openManageAuthorizedSpaces()
|
||||
is SpaceSelection.Single -> {
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ data class SecurityAndPrivacyState(
|
|||
val isSpace: Boolean,
|
||||
private val permissions: SecurityAndPrivacyPermissions,
|
||||
private val selectableJoinedSpaces: ImmutableSet<SpaceRoom>,
|
||||
private val spaceSelection: SpaceSelection,
|
||||
val eventSink: (SecurityAndPrivacyEvent) -> Unit
|
||||
) {
|
||||
|
||||
|
|
|
|||
|
|
@ -122,6 +122,7 @@ fun aSecurityAndPrivacyState(
|
|||
isKnockEnabled: Boolean = true,
|
||||
isSpace: Boolean = false,
|
||||
selectableJoinedSpaces: Set<SpaceRoom> = emptySet(),
|
||||
spaceSelection: SpaceSelection = SpaceSelection.None,
|
||||
eventSink: (SecurityAndPrivacyEvent) -> Unit = {}
|
||||
) = SecurityAndPrivacyState(
|
||||
editedSettings = editedSettings,
|
||||
|
|
@ -133,5 +134,6 @@ fun aSecurityAndPrivacyState(
|
|||
permissions = permissions,
|
||||
isSpace = isSpace,
|
||||
selectableJoinedSpaces = selectableJoinedSpaces.toImmutableSet(),
|
||||
spaceSelection = SpaceSelection.None,
|
||||
eventSink = eventSink,
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue