mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-10-31 16:22:49 +00:00
Merge pull request #7588 from element-hq/feature/bma/avoidNullableCallback
Limit usage of nullable callback.
This commit is contained in:
+2
-2
@@ -21,14 +21,14 @@ interface RoomMemberModerationRenderer {
|
||||
*
|
||||
* @param state the state produced by the moderation presenter.
|
||||
* @param onSelectAction called when the user picks an action, so the host screen can navigate if that action needs its own screen.
|
||||
* @param onAvatarClick called when the user taps the member's avatar, or `null` to make it non-interactive.
|
||||
* @param onAvatarClick called when the user taps the member's avatar, only if the user has an avatar.
|
||||
* @param modifier layout modifier for the container.
|
||||
*/
|
||||
@Composable
|
||||
fun Render(
|
||||
state: RoomMemberModerationState,
|
||||
onSelectAction: (ModerationAction, MatrixUser) -> Unit,
|
||||
onAvatarClick: ((MatrixUser) -> Unit)?,
|
||||
onAvatarClick: (MatrixUser) -> Unit,
|
||||
modifier: Modifier,
|
||||
)
|
||||
}
|
||||
|
||||
+7
-2
@@ -25,11 +25,16 @@ class DefaultRoomMemberModerationRenderer : RoomMemberModerationRenderer {
|
||||
override fun Render(
|
||||
state: RoomMemberModerationState,
|
||||
onSelectAction: (ModerationAction, MatrixUser) -> Unit,
|
||||
onAvatarClick: ((MatrixUser) -> Unit)?,
|
||||
onAvatarClick: (MatrixUser) -> Unit,
|
||||
modifier: Modifier
|
||||
) {
|
||||
if (state is InternalRoomMemberModerationState) {
|
||||
RoomMemberModerationView(modifier = modifier, state = state, onSelectAction = onSelectAction, onAvatarClick = onAvatarClick)
|
||||
RoomMemberModerationView(
|
||||
modifier = modifier,
|
||||
state = state,
|
||||
onSelectAction = onSelectAction,
|
||||
onAvatarClick = onAvatarClick,
|
||||
)
|
||||
} else {
|
||||
SideEffect {
|
||||
Timber.d("RoomMemberModerationRenderer: Render called with unsupported state: $state")
|
||||
|
||||
+4
-4
@@ -66,7 +66,7 @@ import timber.log.Timber
|
||||
fun RoomMemberModerationView(
|
||||
state: InternalRoomMemberModerationState,
|
||||
onSelectAction: (ModerationAction, MatrixUser) -> Unit,
|
||||
onAvatarClick: ((MatrixUser) -> Unit)?,
|
||||
onAvatarClick: (MatrixUser) -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
Box(modifier = modifier) {
|
||||
@@ -218,7 +218,7 @@ private fun RoomMemberActionsBottomSheet(
|
||||
user: MatrixUser,
|
||||
actions: ImmutableList<ModerationActionState>,
|
||||
onSelectAction: (ModerationAction, MatrixUser) -> Unit,
|
||||
onAvatarClick: ((MatrixUser) -> Unit)? = null,
|
||||
onAvatarClick: (MatrixUser) -> Unit,
|
||||
onDismiss: () -> Unit,
|
||||
) {
|
||||
val coroutineScope = rememberCoroutineScope()
|
||||
@@ -248,10 +248,10 @@ private fun RoomMemberActionsBottomSheet(
|
||||
modifier = Modifier
|
||||
.padding(bottom = 24.dp)
|
||||
.align(Alignment.CenterHorizontally)
|
||||
.clickable(enabled = user.avatarUrl != null && onAvatarClick != null) {
|
||||
.clickable(enabled = user.avatarUrl != null) {
|
||||
coroutineScope.launch {
|
||||
bottomSheetState.hide()
|
||||
onAvatarClick?.invoke(user)
|
||||
onAvatarClick(user)
|
||||
onDismiss()
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -218,7 +218,7 @@ class RoomMemberModerationViewTest : RobolectricTest() {
|
||||
private fun AndroidComposeUiTest<ComponentActivity>.setRoomMemberModerationView(
|
||||
state: InternalRoomMemberModerationState,
|
||||
onSelectAction: (ModerationAction, MatrixUser) -> Unit = EnsureNeverCalledWithTwoParams(),
|
||||
onAvatarClick: ((MatrixUser) -> Unit)? = EnsureNeverCalledWithParam(),
|
||||
onAvatarClick: (MatrixUser) -> Unit = EnsureNeverCalledWithParam(),
|
||||
) {
|
||||
setSafeContent {
|
||||
RoomMemberModerationView(
|
||||
|
||||
Reference in New Issue
Block a user