@@ -62,6 +62,7 @@ import com.airbnb.epoxy.EpoxyModel
62
62
import com.airbnb.epoxy.OnModelBuildFinishedListener
63
63
import com.airbnb.epoxy.addGlidePreloader
64
64
import com.airbnb.epoxy.glidePreloader
65
+ import com.airbnb.mvrx.Fail
65
66
import com.airbnb.mvrx.args
66
67
import com.airbnb.mvrx.fragmentViewModel
67
68
import com.airbnb.mvrx.withState
@@ -161,6 +162,7 @@ import im.vector.app.features.home.room.detail.composer.SendMode
161
162
import im.vector.app.features.home.room.detail.composer.boolean
162
163
import im.vector.app.features.home.room.detail.composer.voice.VoiceMessageRecorderView
163
164
import im.vector.app.features.home.room.detail.composer.voice.VoiceMessageRecorderView.RecordingUiState
165
+ import im.vector.app.features.home.room.detail.error.RoomNotFound
164
166
import im.vector.app.features.home.room.detail.readreceipts.DisplayReadReceiptsBottomSheet
165
167
import im.vector.app.features.home.room.detail.timeline.TimelineEventController
166
168
import im.vector.app.features.home.room.detail.timeline.action.EventSharedAction
@@ -992,9 +994,9 @@ class TimelineFragment :
992
994
views.jumpToBottomView.debouncedClicks {
993
995
timelineViewModel.handle(RoomDetailAction .ExitTrackingUnreadMessagesState )
994
996
views.jumpToBottomView.visibility = View .INVISIBLE
995
- if (! timelineViewModel.timeline.isLive) {
997
+ if (timelineViewModel.timeline? .isLive == false ) {
996
998
scrollOnNewMessageCallback.forceScrollOnNextUpdate()
997
- timelineViewModel.timeline.restartWithEventId(null )
999
+ timelineViewModel.timeline? .restartWithEventId(null )
998
1000
} else {
999
1001
layoutManager.scrollToPosition(0 )
1000
1002
}
@@ -1224,12 +1226,12 @@ class TimelineFragment :
1224
1226
}
1225
1227
}
1226
1228
1227
- private fun handleSearchAction () {
1229
+ private fun handleSearchAction () = withState(timelineViewModel) { state ->
1228
1230
navigator.openSearch(
1229
1231
context = requireContext(),
1230
1232
roomId = timelineArgs.roomId,
1231
- roomDisplayName = timelineViewModel.getRoomSummary ()?.displayName,
1232
- roomAvatarUrl = timelineViewModel.getRoomSummary ()?.avatarUrl
1233
+ roomDisplayName = state.asyncRoomSummary ()?.displayName,
1234
+ roomAvatarUrl = state.asyncRoomSummary ()?.avatarUrl
1233
1235
)
1234
1236
}
1235
1237
@@ -1640,6 +1642,10 @@ class TimelineFragment :
1640
1642
1641
1643
override fun invalidate () = withState(timelineViewModel, messageComposerViewModel) { mainState, messageComposerState ->
1642
1644
invalidateOptionsMenu()
1645
+ if (mainState.asyncRoomSummary is Fail ) {
1646
+ handleRoomSummaryFailure(mainState.asyncRoomSummary)
1647
+ return @withState
1648
+ }
1643
1649
val summary = mainState.asyncRoomSummary()
1644
1650
renderToolbar(summary)
1645
1651
renderTypingMessageNotification(summary, mainState)
@@ -1695,6 +1701,23 @@ class TimelineFragment :
1695
1701
updateLiveLocationIndicator(mainState.isSharingLiveLocation)
1696
1702
}
1697
1703
1704
+ private fun handleRoomSummaryFailure (asyncRoomSummary : Fail <RoomSummary >) {
1705
+ views.roomNotFound.isVisible = true
1706
+ views.roomNotFoundText.text = when (asyncRoomSummary.error) {
1707
+ is RoomNotFound -> {
1708
+ getString(
1709
+ R .string.timeline_error_room_not_found,
1710
+ if (vectorPreferences.developerMode()) {
1711
+ " \n Developer info: $timelineArgs "
1712
+ } else {
1713
+ " "
1714
+ }
1715
+ )
1716
+ }
1717
+ else -> errorFormatter.toHumanReadable(asyncRoomSummary.error)
1718
+ }
1719
+ }
1720
+
1698
1721
private fun updateLiveLocationIndicator (isSharingLiveLocation : Boolean ) {
1699
1722
views.liveLocationStatusIndicator.isVisible = isSharingLiveLocation
1700
1723
}
@@ -2520,15 +2543,19 @@ class TimelineFragment :
2520
2543
* Navigate to Threads timeline for the specified rootThreadEventId
2521
2544
* using the ThreadsActivity.
2522
2545
*/
2523
- private fun navigateToThreadTimeline (rootThreadEventId : String , startsThread : Boolean = false, showKeyboard : Boolean = false) {
2546
+ private fun navigateToThreadTimeline (
2547
+ rootThreadEventId : String ,
2548
+ startsThread : Boolean = false,
2549
+ showKeyboard : Boolean = false,
2550
+ ) = withState(timelineViewModel) { state ->
2524
2551
analyticsTracker.capture(Interaction .Name .MobileRoomThreadSummaryItem .toAnalyticsInteraction())
2525
2552
context?.let {
2526
2553
val roomThreadDetailArgs = ThreadTimelineArgs (
2527
2554
startsThread = startsThread,
2528
2555
roomId = timelineArgs.roomId,
2529
- displayName = timelineViewModel.getRoomSummary ()?.displayName,
2530
- avatarUrl = timelineViewModel.getRoomSummary ()?.avatarUrl,
2531
- roomEncryptionTrustLevel = timelineViewModel.getRoomSummary ()?.roomEncryptionTrustLevel,
2556
+ displayName = state.asyncRoomSummary ()?.displayName,
2557
+ avatarUrl = state.asyncRoomSummary ()?.avatarUrl,
2558
+ roomEncryptionTrustLevel = state.asyncRoomSummary ()?.roomEncryptionTrustLevel,
2532
2559
rootThreadEventId = rootThreadEventId,
2533
2560
showKeyboard = showKeyboard
2534
2561
)
@@ -2559,14 +2586,14 @@ class TimelineFragment :
2559
2586
* Navigate to Threads list for the current room
2560
2587
* using the ThreadsActivity.
2561
2588
*/
2562
- private fun navigateToThreadList () {
2589
+ private fun navigateToThreadList () = withState(timelineViewModel) { state ->
2563
2590
analyticsTracker.capture(Interaction .Name .MobileRoomThreadListButton .toAnalyticsInteraction())
2564
2591
context?.let {
2565
2592
val roomThreadDetailArgs = ThreadTimelineArgs (
2566
2593
roomId = timelineArgs.roomId,
2567
- displayName = timelineViewModel.getRoomSummary ()?.displayName,
2568
- roomEncryptionTrustLevel = timelineViewModel.getRoomSummary ()?.roomEncryptionTrustLevel,
2569
- avatarUrl = timelineViewModel.getRoomSummary ()?.avatarUrl
2594
+ displayName = state.asyncRoomSummary ()?.displayName,
2595
+ roomEncryptionTrustLevel = state.asyncRoomSummary ()?.roomEncryptionTrustLevel,
2596
+ avatarUrl = state.asyncRoomSummary ()?.avatarUrl
2570
2597
)
2571
2598
navigator.openThreadList(it, roomThreadDetailArgs)
2572
2599
}
0 commit comments