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