From d6e6092eeac4ca73373b39ccd5596f3ade9fd0e3 Mon Sep 17 00:00:00 2001 From: ganfra Date: Tue, 14 Jan 2020 19:14:15 +0100 Subject: [PATCH] Profile: add PowerLevelContent for building future actions + fix divider --- .../roommemberprofile/RoomMemberProfileController.kt | 7 ++++++- .../roommemberprofile/RoomMemberProfileViewModel.kt | 4 ++++ .../roommemberprofile/RoomMemberProfileViewState.kt | 2 ++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileController.kt b/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileController.kt index 1de8c29f89..a77b34b7ab 100644 --- a/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileController.kt +++ b/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileController.kt @@ -56,6 +56,7 @@ class RoomMemberProfileController @Inject constructor(private val stringProvider title = ignoreActionTitle, destructive = true, editable = false, + divider = false, action = { callback?.onIgnoreClicked() } ) } @@ -85,19 +86,23 @@ class RoomMemberProfileController @Inject constructor(private val stringProvider title = stringProvider.getString(R.string.room_member_jump_to_read_receipt), action = { callback?.onJumpToReadReceiptClicked() } ) + + val ignoreActionTitle = state.buildIgnoreActionTitle() + buildProfileAction( id = "mention", title = stringProvider.getString(R.string.room_participants_action_mention), editable = false, + divider = ignoreActionTitle != null, action = { callback?.onMentionClicked() } ) - val ignoreActionTitle = state.buildIgnoreActionTitle() if (ignoreActionTitle != null) { buildProfileAction( id = "ignore", title = ignoreActionTitle, destructive = true, editable = false, + divider = false, action = { callback?.onIgnoreClicked() } ) } diff --git a/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileViewModel.kt b/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileViewModel.kt index 757318b1d2..737539937b 100644 --- a/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileViewModel.kt +++ b/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileViewModel.kt @@ -154,6 +154,10 @@ class RoomMemberProfileViewModel @AssistedInject constructor(@Assisted private v roomSummaryLive.execute { copy(isRoomEncrypted = it.invoke()?.isEncrypted == true) } + powerLevelsContentLive.execute { + copy(powerLevelsContent = it) + } + Observable .combineLatest( roomSummaryLive, diff --git a/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileViewState.kt b/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileViewState.kt index ff59eb0f03..ba079e9996 100644 --- a/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileViewState.kt +++ b/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileViewState.kt @@ -20,6 +20,7 @@ package im.vector.riotx.features.roommemberprofile import com.airbnb.mvrx.Async import com.airbnb.mvrx.MvRxState import com.airbnb.mvrx.Uninitialized +import im.vector.matrix.android.api.session.room.model.PowerLevelsContent import im.vector.matrix.android.api.util.MatrixItem data class RoomMemberProfileViewState( @@ -29,6 +30,7 @@ data class RoomMemberProfileViewState( val isMine: Boolean = false, val isIgnored: Async = Uninitialized, val isRoomEncrypted: Boolean = false, + val powerLevelsContent: Async = Uninitialized, val userPowerLevelString: Async = Uninitialized, val userMatrixItem: Async = Uninitialized ) : MvRxState {