-
Notifications
You must be signed in to change notification settings - Fork 741
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#4319: Fix DM navigation in member profile screen #5292
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Open direct message screen when clicking on DM button in the space members list |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,7 @@ import im.vector.app.core.extensions.exhaustive | |
import im.vector.app.core.mvrx.runCatchingToAsync | ||
import im.vector.app.core.platform.VectorViewModel | ||
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.home.room.detail.timeline.helper.MatrixItemColorProvider | ||
import im.vector.app.features.powerlevel.PowerLevelsFlowFactory | ||
|
@@ -66,6 +67,7 @@ class RoomMemberProfileViewModel @AssistedInject constructor( | |
@Assisted private val initialState: RoomMemberProfileViewState, | ||
private val stringProvider: StringProvider, | ||
private val matrixItemColorProvider: MatrixItemColorProvider, | ||
private val directRoomHelper: DirectRoomHelper, | ||
private val session: Session | ||
) : VectorViewModel<RoomMemberProfileViewState, RoomMemberProfileAction, RoomMemberProfileViewEvents>(initialState) { | ||
|
||
|
@@ -167,9 +169,25 @@ class RoomMemberProfileViewModel @AssistedInject constructor( | |
is RoomMemberProfileAction.KickUser -> handleKickAction(action) | ||
RoomMemberProfileAction.InviteUser -> handleInviteAction() | ||
is RoomMemberProfileAction.SetUserColorOverride -> handleSetUserColorOverride(action) | ||
is RoomMemberProfileAction.OpenOrCreateDm -> handleOpenOrCreateDm(action) | ||
}.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)) | ||
} | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This code is duplicate of the code in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the code which is duplicated? Normally, I moved out this method There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, my bad, sorry |
||
|
||
private fun handleSetUserColorOverride(action: RoomMemberProfileAction.SetUserColorOverride) { | ||
val newOverrideColorSpecs = session.accountDataService() | ||
.getUserAccountDataEvent(UserAccountDataTypes.TYPE_OVERRIDE_COLORS) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has the effect to add a room to the Activity stack. This is fine, but this is a side effect of this change.
So when the user will close the RoomDetailActivity with the DM, they will see the RoomMemberProfile Fragment again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes It was intended. In my opinion it is consistent to go back to member profile screen in term of navigation. But I will try to make a video to explain the changes as you suggested.