Skip to content

Commit

Permalink
Merge pull request #3892 from element-hq/feature/fga/room_list_securi…
Browse files Browse the repository at this point in the history
…ty_banner_empty_state

fix : display security banner for room list empty state
  • Loading branch information
ganfra authored Nov 19, 2024
2 parents 6bce3d5 + 71e65cd commit 03d9f3d
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ open class RoomListContentStateProvider : PreviewParameterProvider<RoomListConte
aRoomsContentState(summaries = persistentListOf()),
aSkeletonContentState(),
anEmptyContentState(),
anEmptyContentState(securityBannerState = SecurityBannerState.SetUpRecovery),
aRoomsContentState(securityBannerState = SecurityBannerState.NeedsNativeSlidingSyncMigration),
)
}
Expand All @@ -37,4 +38,8 @@ internal fun aRoomsContentState(

internal fun aSkeletonContentState() = RoomListContentState.Skeleton(16)

internal fun anEmptyContentState() = RoomListContentState.Empty
internal fun anEmptyContentState(
securityBannerState: SecurityBannerState = SecurityBannerState.None,
) = RoomListContentState.Empty(
securityBannerState = securityBannerState,
)
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,11 @@ class RoomListPresenter @Inject constructor(
client.isNativeSlidingSyncSupported() && !client.isUsingNativeSlidingSync()
}.getOrNull().orFalse()
}
val securityBannerState by rememberSecurityBannerState(securityBannerDismissed, needsSlidingSyncMigration)
return when {
showEmpty -> RoomListContentState.Empty
showEmpty -> RoomListContentState.Empty(securityBannerState = securityBannerState)
showSkeleton -> RoomListContentState.Skeleton(count = 16)
else -> {
val securityBannerState by rememberSecurityBannerState(securityBannerDismissed, needsSlidingSyncMigration)
RoomListContentState.Rooms(
securityBannerState = securityBannerState,
fullScreenIntentPermissionsState = fullScreenIntentPermissionsPresenter.present(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ enum class SecurityBannerState {
@Immutable
sealed interface RoomListContentState {
data class Skeleton(val count: Int) : RoomListContentState
data object Empty : RoomListContentState
data class Empty(
val securityBannerState: SecurityBannerState,
) : RoomListContentState
data class Rooms(
val securityBannerState: SecurityBannerState,
val fullScreenIntentPermissionsState: FullScreenIntentPermissionsState,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ fun RoomListContentView(
}
is RoomListContentState.Empty -> {
EmptyView(
state = contentState,
eventSink = eventSink,
onSetUpRecoveryClick = onSetUpRecoveryClick,
onConfirmRecoveryKeyClick = onConfirmRecoveryKeyClick,
onCreateRoomClick = onCreateRoomClick,
)
}
Expand Down Expand Up @@ -110,21 +114,44 @@ private fun SkeletonView(count: Int, modifier: Modifier = Modifier) {

@Composable
private fun EmptyView(
state: RoomListContentState.Empty,
eventSink: (RoomListEvents) -> Unit,
onSetUpRecoveryClick: () -> Unit,
onConfirmRecoveryKeyClick: () -> Unit,
onCreateRoomClick: () -> Unit,
modifier: Modifier = Modifier
modifier: Modifier = Modifier,
) {
EmptyScaffold(
title = R.string.screen_roomlist_empty_title,
subtitle = R.string.screen_roomlist_empty_message,
action = {
Button(
text = stringResource(CommonStrings.action_start_chat),
leadingIcon = IconSource.Vector(CompoundIcons.Compose()),
onClick = onCreateRoomClick,
)
},
modifier = modifier.fillMaxSize(),
)
Box(modifier.fillMaxSize()) {
EmptyScaffold(
title = R.string.screen_roomlist_empty_title,
subtitle = R.string.screen_roomlist_empty_message,
action = {
Button(
text = stringResource(CommonStrings.action_start_chat),
leadingIcon = IconSource.Vector(CompoundIcons.Compose()),
onClick = onCreateRoomClick,
)
},
modifier = Modifier.align(Alignment.Center),
)
Box {
when (state.securityBannerState) {
SecurityBannerState.SetUpRecovery -> {
SetUpRecoveryKeyBanner(
onContinueClick = onSetUpRecoveryClick,
onDismissClick = { eventSink(RoomListEvents.DismissBanner) }
)
}
SecurityBannerState.RecoveryKeyConfirmation -> {
ConfirmRecoveryKeyBanner(
onContinueClick = onConfirmRecoveryKeyClick,
onDismissClick = { eventSink(RoomListEvents.DismissBanner) }
)
}
else -> Unit
}
}
}
}

@Composable
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 03d9f3d

Please sign in to comment.