space: add space settings ff and branch it
This commit is contained in:
parent
cfa494bd2c
commit
9a081c496f
5 changed files with 20 additions and 2 deletions
|
|
@ -26,6 +26,8 @@ import io.element.android.libraries.architecture.AsyncAction
|
||||||
import io.element.android.libraries.architecture.Presenter
|
import io.element.android.libraries.architecture.Presenter
|
||||||
import io.element.android.libraries.core.coroutine.mapState
|
import io.element.android.libraries.core.coroutine.mapState
|
||||||
import io.element.android.libraries.di.annotations.SessionCoroutineScope
|
import io.element.android.libraries.di.annotations.SessionCoroutineScope
|
||||||
|
import io.element.android.libraries.featureflag.api.FeatureFlagService
|
||||||
|
import io.element.android.libraries.featureflag.api.FeatureFlags
|
||||||
import io.element.android.libraries.matrix.api.MatrixClient
|
import io.element.android.libraries.matrix.api.MatrixClient
|
||||||
import io.element.android.libraries.matrix.api.core.RoomId
|
import io.element.android.libraries.matrix.api.core.RoomId
|
||||||
import io.element.android.libraries.matrix.api.core.toRoomIdOrAlias
|
import io.element.android.libraries.matrix.api.core.toRoomIdOrAlias
|
||||||
|
|
@ -53,6 +55,7 @@ class SpacePresenter(
|
||||||
private val joinRoom: JoinRoom,
|
private val joinRoom: JoinRoom,
|
||||||
private val acceptDeclineInvitePresenter: Presenter<AcceptDeclineInviteState>,
|
private val acceptDeclineInvitePresenter: Presenter<AcceptDeclineInviteState>,
|
||||||
@SessionCoroutineScope private val sessionCoroutineScope: CoroutineScope,
|
@SessionCoroutineScope private val sessionCoroutineScope: CoroutineScope,
|
||||||
|
private val featureFlagService: FeatureFlagService,
|
||||||
) : Presenter<SpaceState> {
|
) : Presenter<SpaceState> {
|
||||||
private var children by mutableStateOf<ImmutableList<SpaceRoom>>(persistentListOf())
|
private var children by mutableStateOf<ImmutableList<SpaceRoom>>(persistentListOf())
|
||||||
|
|
||||||
|
|
@ -79,6 +82,10 @@ class SpacePresenter(
|
||||||
}
|
}
|
||||||
}.collectAsState()
|
}.collectAsState()
|
||||||
|
|
||||||
|
val isSpaceSettingsEnabled by remember {
|
||||||
|
featureFlagService.isFeatureEnabledFlow(FeatureFlags.SpaceSettings)
|
||||||
|
}.collectAsState(false)
|
||||||
|
|
||||||
val currentSpace by spaceRoomList.currentSpaceFlow.collectAsState()
|
val currentSpace by spaceRoomList.currentSpaceFlow.collectAsState()
|
||||||
val (joinActions, setJoinActions) = remember { mutableStateOf(emptyMap<RoomId, AsyncAction<Unit>>()) }
|
val (joinActions, setJoinActions) = remember { mutableStateOf(emptyMap<RoomId, AsyncAction<Unit>>()) }
|
||||||
|
|
||||||
|
|
@ -129,6 +136,7 @@ class SpacePresenter(
|
||||||
joinActions = joinActions.toImmutableMap(),
|
joinActions = joinActions.toImmutableMap(),
|
||||||
acceptDeclineInviteState = acceptDeclineInviteState,
|
acceptDeclineInviteState = acceptDeclineInviteState,
|
||||||
topicViewerState = topicViewerState,
|
topicViewerState = topicViewerState,
|
||||||
|
canAccessSpaceSettings = isSpaceSettingsEnabled,
|
||||||
eventSink = ::handleEvent,
|
eventSink = ::handleEvent,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ data class SpaceState(
|
||||||
val joinActions: ImmutableMap<RoomId, AsyncAction<Unit>>,
|
val joinActions: ImmutableMap<RoomId, AsyncAction<Unit>>,
|
||||||
val acceptDeclineInviteState: AcceptDeclineInviteState,
|
val acceptDeclineInviteState: AcceptDeclineInviteState,
|
||||||
val topicViewerState: TopicViewerState,
|
val topicViewerState: TopicViewerState,
|
||||||
|
val canAccessSpaceSettings: Boolean,
|
||||||
val eventSink: (SpaceEvents) -> Unit
|
val eventSink: (SpaceEvents) -> Unit
|
||||||
) {
|
) {
|
||||||
fun isJoining(spaceId: RoomId): Boolean = joinActions[spaceId] == AsyncAction.Loading
|
fun isJoining(spaceId: RoomId): Boolean = joinActions[spaceId] == AsyncAction.Loading
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,7 @@ fun aSpaceState(
|
||||||
hasMoreToLoad: Boolean = true,
|
hasMoreToLoad: Boolean = true,
|
||||||
acceptDeclineInviteState: AcceptDeclineInviteState = anAcceptDeclineInviteState(),
|
acceptDeclineInviteState: AcceptDeclineInviteState = anAcceptDeclineInviteState(),
|
||||||
topicViewerState: TopicViewerState = TopicViewerState.Hidden,
|
topicViewerState: TopicViewerState = TopicViewerState.Hidden,
|
||||||
|
canAccessSpaceSettings: Boolean = true,
|
||||||
eventSink: (SpaceEvents) -> Unit = { },
|
eventSink: (SpaceEvents) -> Unit = { },
|
||||||
) = SpaceState(
|
) = SpaceState(
|
||||||
currentSpace = parentSpace,
|
currentSpace = parentSpace,
|
||||||
|
|
@ -63,6 +64,7 @@ fun aSpaceState(
|
||||||
joinActions = joinActions.toImmutableMap(),
|
joinActions = joinActions.toImmutableMap(),
|
||||||
acceptDeclineInviteState = acceptDeclineInviteState,
|
acceptDeclineInviteState = acceptDeclineInviteState,
|
||||||
topicViewerState = topicViewerState,
|
topicViewerState = topicViewerState,
|
||||||
|
canAccessSpaceSettings = canAccessSpaceSettings,
|
||||||
eventSink = eventSink,
|
eventSink = eventSink,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -88,6 +88,7 @@ fun SpaceView(
|
||||||
topBar = {
|
topBar = {
|
||||||
SpaceViewTopBar(
|
SpaceViewTopBar(
|
||||||
currentSpace = state.currentSpace,
|
currentSpace = state.currentSpace,
|
||||||
|
canAccessSpaceSettings = state.canAccessSpaceSettings,
|
||||||
onBackClick = onBackClick,
|
onBackClick = onBackClick,
|
||||||
onLeaveSpaceClick = onLeaveSpaceClick,
|
onLeaveSpaceClick = onLeaveSpaceClick,
|
||||||
onShareSpace = onShareSpace,
|
onShareSpace = onShareSpace,
|
||||||
|
|
@ -255,6 +256,7 @@ private fun LoadingMoreIndicator(
|
||||||
@Composable
|
@Composable
|
||||||
private fun SpaceViewTopBar(
|
private fun SpaceViewTopBar(
|
||||||
currentSpace: SpaceRoom?,
|
currentSpace: SpaceRoom?,
|
||||||
|
canAccessSpaceSettings: Boolean,
|
||||||
onBackClick: () -> Unit,
|
onBackClick: () -> Unit,
|
||||||
onLeaveSpaceClick: () -> Unit,
|
onLeaveSpaceClick: () -> Unit,
|
||||||
onDetailsClick: () -> Unit,
|
onDetailsClick: () -> Unit,
|
||||||
|
|
@ -275,8 +277,7 @@ private fun SpaceViewTopBar(
|
||||||
avatarData = currentSpace.getAvatarData(AvatarSize.TimelineRoom),
|
avatarData = currentSpace.getAvatarData(AvatarSize.TimelineRoom),
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.clip(roundedCornerShape)
|
.clip(roundedCornerShape)
|
||||||
// TODO enable when screen ready for space
|
.clickable(enabled = canAccessSpaceSettings, onClick = onDetailsClick)
|
||||||
.clickable(enabled = false, onClick = onDetailsClick)
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -75,6 +75,12 @@ enum class FeatureFlags(
|
||||||
title = "Spaces",
|
title = "Spaces",
|
||||||
defaultValue = { true },
|
defaultValue = { true },
|
||||||
isFinished = true,
|
isFinished = true,
|
||||||
|
),
|
||||||
|
SpaceSettings(
|
||||||
|
key = "feature.spaceSettings",
|
||||||
|
title = "Space settings",
|
||||||
|
description = "Allow managing space settings such details, permissions and privacy.",
|
||||||
|
defaultValue = { true },
|
||||||
isFinished = false,
|
isFinished = false,
|
||||||
),
|
),
|
||||||
PrintLogsToLogcat(
|
PrintLogsToLogcat(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue