Profile: add PowerLevelContent for building future actions + fix divider

This commit is contained in:
ganfra 2020-01-14 19:14:15 +01:00
parent 9671a77e5d
commit d6e6092eea
3 changed files with 12 additions and 1 deletions

View File

@ -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() }
)
}

View File

@ -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,

View File

@ -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<Boolean> = Uninitialized,
val isRoomEncrypted: Boolean = false,
val powerLevelsContent: Async<PowerLevelsContent> = Uninitialized,
val userPowerLevelString: Async<String> = Uninitialized,
val userMatrixItem: Async<MatrixItem> = Uninitialized
) : MvRxState {