mirror of
https://github.com/element-hq/element-android
synced 2024-11-24 10:25:35 +03:00
Moving DM creation/opening into the member profile screen
This commit is contained in:
parent
836bf4e11e
commit
46854b4b84
4 changed files with 26 additions and 2 deletions
|
@ -29,4 +29,5 @@ sealed class RoomMemberProfileAction : VectorViewModelAction {
|
||||||
object ShareRoomMemberProfile : RoomMemberProfileAction()
|
object ShareRoomMemberProfile : RoomMemberProfileAction()
|
||||||
data class SetPowerLevel(val previousValue: Int, val newValue: Int, val askForValidation: Boolean) : RoomMemberProfileAction()
|
data class SetPowerLevel(val previousValue: Int, val newValue: Int, val askForValidation: Boolean) : RoomMemberProfileAction()
|
||||||
data class SetUserColorOverride(val newColorSpec: String) : RoomMemberProfileAction()
|
data class SetUserColorOverride(val newColorSpec: String) : RoomMemberProfileAction()
|
||||||
|
data class OpenOrCreateDm(val userId: String) : RoomMemberProfileAction()
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,6 +127,7 @@ class RoomMemberProfileFragment @Inject constructor(
|
||||||
is RoomMemberProfileViewEvents.ShareRoomMemberProfile -> handleShareRoomMemberProfile(it.permalink)
|
is RoomMemberProfileViewEvents.ShareRoomMemberProfile -> handleShareRoomMemberProfile(it.permalink)
|
||||||
is RoomMemberProfileViewEvents.ShowPowerLevelValidation -> handleShowPowerLevelAdminWarning(it)
|
is RoomMemberProfileViewEvents.ShowPowerLevelValidation -> handleShowPowerLevelAdminWarning(it)
|
||||||
is RoomMemberProfileViewEvents.ShowPowerLevelDemoteWarning -> handleShowPowerLevelDemoteWarning(it)
|
is RoomMemberProfileViewEvents.ShowPowerLevelDemoteWarning -> handleShowPowerLevelDemoteWarning(it)
|
||||||
|
is RoomMemberProfileViewEvents.OpenRoom -> handleOpenRoom(it)
|
||||||
is RoomMemberProfileViewEvents.OnKickActionSuccess -> Unit
|
is RoomMemberProfileViewEvents.OnKickActionSuccess -> Unit
|
||||||
is RoomMemberProfileViewEvents.OnSetPowerLevelSuccess -> Unit
|
is RoomMemberProfileViewEvents.OnSetPowerLevelSuccess -> Unit
|
||||||
is RoomMemberProfileViewEvents.OnBanActionSuccess -> Unit
|
is RoomMemberProfileViewEvents.OnBanActionSuccess -> Unit
|
||||||
|
@ -142,6 +143,10 @@ class RoomMemberProfileFragment @Inject constructor(
|
||||||
headerViews.memberProfileIdView.copyOnLongClick()
|
headerViews.memberProfileIdView.copyOnLongClick()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun handleOpenRoom(event: RoomMemberProfileViewEvents.OpenRoom) {
|
||||||
|
navigator.openRoom(requireContext(), event.roomId, null)
|
||||||
|
}
|
||||||
|
|
||||||
private fun handleShowPowerLevelDemoteWarning(event: RoomMemberProfileViewEvents.ShowPowerLevelDemoteWarning) {
|
private fun handleShowPowerLevelDemoteWarning(event: RoomMemberProfileViewEvents.ShowPowerLevelDemoteWarning) {
|
||||||
EditPowerLevelDialogs.showDemoteWarning(requireActivity()) {
|
EditPowerLevelDialogs.showDemoteWarning(requireActivity()) {
|
||||||
viewModel.handle(RoomMemberProfileAction.SetPowerLevel(event.currentValue, event.newValue, false))
|
viewModel.handle(RoomMemberProfileAction.SetPowerLevel(event.currentValue, event.newValue, false))
|
||||||
|
@ -297,8 +302,7 @@ class RoomMemberProfileFragment @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onOpenDmClicked() {
|
override fun onOpenDmClicked() {
|
||||||
roomDetailPendingActionStore.data = RoomDetailPendingAction.OpenOrCreateDm(fragmentArgs.userId)
|
viewModel.handle(RoomMemberProfileAction.OpenOrCreateDm(fragmentArgs.userId))
|
||||||
vectorBaseActivity.finish()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onJumpToReadReceiptClicked() {
|
override fun onJumpToReadReceiptClicked() {
|
||||||
|
|
|
@ -39,4 +39,5 @@ sealed class RoomMemberProfileViewEvents : VectorViewEvents {
|
||||||
) : RoomMemberProfileViewEvents()
|
) : RoomMemberProfileViewEvents()
|
||||||
|
|
||||||
data class ShareRoomMemberProfile(val permalink: String) : RoomMemberProfileViewEvents()
|
data class ShareRoomMemberProfile(val permalink: String) : RoomMemberProfileViewEvents()
|
||||||
|
data class OpenRoom(val roomId: String) : RoomMemberProfileViewEvents()
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@ import im.vector.app.core.extensions.exhaustive
|
||||||
import im.vector.app.core.mvrx.runCatchingToAsync
|
import im.vector.app.core.mvrx.runCatchingToAsync
|
||||||
import im.vector.app.core.platform.VectorViewModel
|
import im.vector.app.core.platform.VectorViewModel
|
||||||
import im.vector.app.core.resources.StringProvider
|
import im.vector.app.core.resources.StringProvider
|
||||||
|
import im.vector.app.features.createdirect.DirectRoomHelper
|
||||||
import im.vector.app.features.displayname.getBestName
|
import im.vector.app.features.displayname.getBestName
|
||||||
import im.vector.app.features.home.room.detail.timeline.helper.MatrixItemColorProvider
|
import im.vector.app.features.home.room.detail.timeline.helper.MatrixItemColorProvider
|
||||||
import im.vector.app.features.powerlevel.PowerLevelsFlowFactory
|
import im.vector.app.features.powerlevel.PowerLevelsFlowFactory
|
||||||
|
@ -66,6 +67,7 @@ class RoomMemberProfileViewModel @AssistedInject constructor(
|
||||||
@Assisted private val initialState: RoomMemberProfileViewState,
|
@Assisted private val initialState: RoomMemberProfileViewState,
|
||||||
private val stringProvider: StringProvider,
|
private val stringProvider: StringProvider,
|
||||||
private val matrixItemColorProvider: MatrixItemColorProvider,
|
private val matrixItemColorProvider: MatrixItemColorProvider,
|
||||||
|
private val directRoomHelper: DirectRoomHelper,
|
||||||
private val session: Session
|
private val session: Session
|
||||||
) : VectorViewModel<RoomMemberProfileViewState, RoomMemberProfileAction, RoomMemberProfileViewEvents>(initialState) {
|
) : VectorViewModel<RoomMemberProfileViewState, RoomMemberProfileAction, RoomMemberProfileViewEvents>(initialState) {
|
||||||
|
|
||||||
|
@ -167,9 +169,25 @@ class RoomMemberProfileViewModel @AssistedInject constructor(
|
||||||
is RoomMemberProfileAction.KickUser -> handleKickAction(action)
|
is RoomMemberProfileAction.KickUser -> handleKickAction(action)
|
||||||
RoomMemberProfileAction.InviteUser -> handleInviteAction()
|
RoomMemberProfileAction.InviteUser -> handleInviteAction()
|
||||||
is RoomMemberProfileAction.SetUserColorOverride -> handleSetUserColorOverride(action)
|
is RoomMemberProfileAction.SetUserColorOverride -> handleSetUserColorOverride(action)
|
||||||
|
is RoomMemberProfileAction.OpenOrCreateDm -> handleOpenOrCreateDm(action)
|
||||||
}.exhaustive
|
}.exhaustive
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun handleOpenOrCreateDm(action: RoomMemberProfileAction.OpenOrCreateDm) {
|
||||||
|
viewModelScope.launch {
|
||||||
|
_viewEvents.post(RoomMemberProfileViewEvents.Loading())
|
||||||
|
val roomId = try {
|
||||||
|
directRoomHelper.ensureDMExists(action.userId)
|
||||||
|
} catch (failure: Throwable) {
|
||||||
|
_viewEvents.post(RoomMemberProfileViewEvents.Failure(failure))
|
||||||
|
return@launch
|
||||||
|
}
|
||||||
|
if (roomId != initialState.roomId) {
|
||||||
|
_viewEvents.post(RoomMemberProfileViewEvents.OpenRoom(roomId = roomId))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun handleSetUserColorOverride(action: RoomMemberProfileAction.SetUserColorOverride) {
|
private fun handleSetUserColorOverride(action: RoomMemberProfileAction.SetUserColorOverride) {
|
||||||
val newOverrideColorSpecs = session.accountDataService()
|
val newOverrideColorSpecs = session.accountDataService()
|
||||||
.getUserAccountDataEvent(UserAccountDataTypes.TYPE_OVERRIDE_COLORS)
|
.getUserAccountDataEvent(UserAccountDataTypes.TYPE_OVERRIDE_COLORS)
|
||||||
|
|
Loading…
Reference in a new issue