Fix latest small bugs

This commit is contained in:
Benoit Marty 2021-12-31 15:22:48 +01:00
parent 1cb91ca5df
commit a7b72ed39d
4 changed files with 16 additions and 6 deletions

View file

@ -42,6 +42,7 @@ import im.vector.app.features.home.HomeDetailViewModel
import im.vector.app.features.home.PromoteRestrictedViewModel
import im.vector.app.features.home.UnknownDeviceDetectorSharedViewModel
import im.vector.app.features.home.UnreadMessagesSharedViewModel
import im.vector.app.features.home.UserColorAccountDataViewModel
import im.vector.app.features.home.room.breadcrumbs.BreadcrumbsViewModel
import im.vector.app.features.home.room.detail.RoomDetailViewModel
import im.vector.app.features.home.room.detail.composer.MessageComposerViewModel
@ -412,6 +413,11 @@ interface MavericksViewModelModule {
@MavericksViewModelKey(RoomMemberProfileViewModel::class)
fun roomMemberProfileViewModelFactory(factory: RoomMemberProfileViewModel.Factory): MavericksAssistedViewModelFactory<*, *>
@Binds
@IntoMap
@MavericksViewModelKey(UserColorAccountDataViewModel::class)
fun userColorAccountDataViewModelFactory(factory: UserColorAccountDataViewModel.Factory): MavericksAssistedViewModelFactory<*, *>
@Binds
@IntoMap
@MavericksViewModelKey(RoomPreviewViewModel::class)

View file

@ -28,5 +28,5 @@ sealed class RoomMemberProfileAction : VectorViewModelAction {
object VerifyUser : RoomMemberProfileAction()
object ShareRoomMemberProfile : RoomMemberProfileAction()
data class SetPowerLevel(val previousValue: Int, val newValue: Int, val askForValidation: Boolean) : RoomMemberProfileAction()
data class SetUserColorOverride(val newColor: String) : RoomMemberProfileAction()
data class SetUserColorOverride(val newColorSpec: String) : RoomMemberProfileAction()
}

View file

@ -179,7 +179,7 @@ class RoomMemberProfileController @Inject constructor(
editable = false,
title = stringProvider.getString(R.string.room_member_override_nick_color),
subtitle = state.userColorOverride,
divider = false,
divider = !state.isMine,
action = { callback?.onOverrideColorClicked() }
)

View file

@ -174,10 +174,14 @@ class RoomMemberProfileViewModel @AssistedInject constructor(
}
private fun handleSetUserColorOverride(action: RoomMemberProfileAction.SetUserColorOverride) {
val newOverrideColorSpecs = session.accountDataService().getUserAccountDataEvent(UserAccountDataTypes.TYPE_OVERRIDE_COLORS)
?.content?.toMap().orEmpty().toMutableMap()
if (matrixItemColorProvider.setOverrideColor(initialState.userId, action.newColor)) {
newOverrideColorSpecs[initialState.userId] = action.newColor
val newOverrideColorSpecs = session.accountDataService()
.getUserAccountDataEvent(UserAccountDataTypes.TYPE_OVERRIDE_COLORS)
?.content
?.toModel<Map<String, String>>()
.orEmpty()
.toMutableMap()
if (matrixItemColorProvider.setOverrideColor(initialState.userId, action.newColorSpec)) {
newOverrideColorSpecs[initialState.userId] = action.newColorSpec
} else {
newOverrideColorSpecs.remove(initialState.userId)
}