Skip to content

Commit

Permalink
Merge pull request #6549 from vector-im/feature/bma/fix_6514
Browse files Browse the repository at this point in the history
Just go back to the timeline if the user is already viewing the DM with the other user.
  • Loading branch information
bmarty authored Jul 18, 2022
2 parents 90c177c + d10d8d7 commit cdbc197
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog.d/6549.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix infinite loading when opening a DM when the current room is the same DM.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package im.vector.app.features.home.room.detail

sealed class RoomDetailPendingAction {
object DoNothing : RoomDetailPendingAction()
data class JumpToReadReceipt(val userId: String) : RoomDetailPendingAction()
data class MentionUser(val userId: String) : RoomDetailPendingAction()
data class OpenRoom(val roomId: String, val closeCurrentRoom: Boolean = false) : RoomDetailPendingAction()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1323,6 +1323,7 @@ class TimelineFragment @Inject constructor(

private fun handlePendingAction(roomDetailPendingAction: RoomDetailPendingAction) {
when (roomDetailPendingAction) {
RoomDetailPendingAction.DoNothing -> Unit
is RoomDetailPendingAction.JumpToReadReceipt ->
timelineViewModel.handle(RoomDetailAction.JumpToReadReceipt(roomDetailPendingAction.userId))
is RoomDetailPendingAction.MentionUser ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ class RoomMemberProfileFragment @Inject constructor(
is RoomMemberProfileViewEvents.OnBanActionSuccess -> Unit
is RoomMemberProfileViewEvents.OnIgnoreActionSuccess -> Unit
is RoomMemberProfileViewEvents.OnInviteActionSuccess -> Unit
RoomMemberProfileViewEvents.GoBack -> handleGoBack()
}
}
setupLongClicks()
Expand Down Expand Up @@ -309,6 +310,11 @@ class RoomMemberProfileFragment @Inject constructor(
viewModel.handle(RoomMemberProfileAction.OpenOrCreateDm(fragmentArgs.userId))
}

private fun handleGoBack() {
roomDetailPendingActionStore.data = RoomDetailPendingAction.DoNothing
vectorBaseActivity.finish()
}

override fun onJumpToReadReceiptClicked() {
roomDetailPendingActionStore.data = RoomDetailPendingAction.JumpToReadReceipt(fragmentArgs.userId)
vectorBaseActivity.finish()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,5 @@ sealed class RoomMemberProfileViewEvents : VectorViewEvents {

data class ShareRoomMemberProfile(val permalink: String) : RoomMemberProfileViewEvents()
data class OpenRoom(val roomId: String) : RoomMemberProfileViewEvents()
object GoBack : RoomMemberProfileViewEvents()
}
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@ class RoomMemberProfileViewModel @AssistedInject constructor(
}
if (roomId != initialState.roomId) {
_viewEvents.post(RoomMemberProfileViewEvents.OpenRoom(roomId = roomId))
} else {
// Just go back to the previous screen (timeline)
_viewEvents.post(RoomMemberProfileViewEvents.GoBack)
}
}
}
Expand Down

0 comments on commit cdbc197

Please sign in to comment.