Skip to content

Commit cdbc197

Browse files
authored
Merge pull request #6549 from vector-im/feature/bma/fix_6514
Just go back to the timeline if the user is already viewing the DM with the other user.
2 parents 90c177c + d10d8d7 commit cdbc197

File tree

6 files changed

+13
-0
lines changed

6 files changed

+13
-0
lines changed

changelog.d/6549.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix infinite loading when opening a DM when the current room is the same DM.

vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailPendingAction.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package im.vector.app.features.home.room.detail
1818

1919
sealed class RoomDetailPendingAction {
20+
object DoNothing : RoomDetailPendingAction()
2021
data class JumpToReadReceipt(val userId: String) : RoomDetailPendingAction()
2122
data class MentionUser(val userId: String) : RoomDetailPendingAction()
2223
data class OpenRoom(val roomId: String, val closeCurrentRoom: Boolean = false) : RoomDetailPendingAction()

vector/src/main/java/im/vector/app/features/home/room/detail/TimelineFragment.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1323,6 +1323,7 @@ class TimelineFragment @Inject constructor(
13231323

13241324
private fun handlePendingAction(roomDetailPendingAction: RoomDetailPendingAction) {
13251325
when (roomDetailPendingAction) {
1326+
RoomDetailPendingAction.DoNothing -> Unit
13261327
is RoomDetailPendingAction.JumpToReadReceipt ->
13271328
timelineViewModel.handle(RoomDetailAction.JumpToReadReceipt(roomDetailPendingAction.userId))
13281329
is RoomDetailPendingAction.MentionUser ->

vector/src/main/java/im/vector/app/features/roommemberprofile/RoomMemberProfileFragment.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ class RoomMemberProfileFragment @Inject constructor(
136136
is RoomMemberProfileViewEvents.OnBanActionSuccess -> Unit
137137
is RoomMemberProfileViewEvents.OnIgnoreActionSuccess -> Unit
138138
is RoomMemberProfileViewEvents.OnInviteActionSuccess -> Unit
139+
RoomMemberProfileViewEvents.GoBack -> handleGoBack()
139140
}
140141
}
141142
setupLongClicks()
@@ -309,6 +310,11 @@ class RoomMemberProfileFragment @Inject constructor(
309310
viewModel.handle(RoomMemberProfileAction.OpenOrCreateDm(fragmentArgs.userId))
310311
}
311312

313+
private fun handleGoBack() {
314+
roomDetailPendingActionStore.data = RoomDetailPendingAction.DoNothing
315+
vectorBaseActivity.finish()
316+
}
317+
312318
override fun onJumpToReadReceiptClicked() {
313319
roomDetailPendingActionStore.data = RoomDetailPendingAction.JumpToReadReceipt(fragmentArgs.userId)
314320
vectorBaseActivity.finish()

vector/src/main/java/im/vector/app/features/roommemberprofile/RoomMemberProfileViewEvents.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,5 @@ sealed class RoomMemberProfileViewEvents : VectorViewEvents {
4040

4141
data class ShareRoomMemberProfile(val permalink: String) : RoomMemberProfileViewEvents()
4242
data class OpenRoom(val roomId: String) : RoomMemberProfileViewEvents()
43+
object GoBack : RoomMemberProfileViewEvents()
4344
}

vector/src/main/java/im/vector/app/features/roommemberprofile/RoomMemberProfileViewModel.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,9 @@ class RoomMemberProfileViewModel @AssistedInject constructor(
183183
}
184184
if (roomId != initialState.roomId) {
185185
_viewEvents.post(RoomMemberProfileViewEvents.OpenRoom(roomId = roomId))
186+
} else {
187+
// Just go back to the previous screen (timeline)
188+
_viewEvents.post(RoomMemberProfileViewEvents.GoBack)
186189
}
187190
}
188191
}

0 commit comments

Comments
 (0)