diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineFragment.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineFragment.kt index c4d29e6819..80e41c9a67 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineFragment.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineFragment.kt @@ -62,6 +62,7 @@ import com.airbnb.epoxy.EpoxyModel import com.airbnb.epoxy.OnModelBuildFinishedListener import com.airbnb.epoxy.addGlidePreloader import com.airbnb.epoxy.glidePreloader +import com.airbnb.mvrx.Fail import com.airbnb.mvrx.args import com.airbnb.mvrx.fragmentViewModel import com.airbnb.mvrx.withState @@ -161,6 +162,7 @@ import im.vector.app.features.home.room.detail.composer.SendMode import im.vector.app.features.home.room.detail.composer.boolean import im.vector.app.features.home.room.detail.composer.voice.VoiceMessageRecorderView import im.vector.app.features.home.room.detail.composer.voice.VoiceMessageRecorderView.RecordingUiState +import im.vector.app.features.home.room.detail.error.RoomNotFound import im.vector.app.features.home.room.detail.readreceipts.DisplayReadReceiptsBottomSheet import im.vector.app.features.home.room.detail.timeline.TimelineEventController import im.vector.app.features.home.room.detail.timeline.action.EventSharedAction @@ -1640,6 +1642,10 @@ class TimelineFragment : override fun invalidate() = withState(timelineViewModel, messageComposerViewModel) { mainState, messageComposerState -> invalidateOptionsMenu() + if (mainState.asyncRoomSummary is Fail) { + handleRoomSummaryFailure(mainState.asyncRoomSummary) + return@withState + } val summary = mainState.asyncRoomSummary() renderToolbar(summary) renderTypingMessageNotification(summary, mainState) @@ -1695,6 +1701,23 @@ class TimelineFragment : updateLiveLocationIndicator(mainState.isSharingLiveLocation) } + private fun handleRoomSummaryFailure(asyncRoomSummary: Fail) { + views.roomNotFound.isVisible = true + views.roomNotFoundText.text = when (asyncRoomSummary.error) { + is RoomNotFound -> { + getString( + R.string.timeline_error_room_not_found, + if (vectorPreferences.developerMode()) { + "\nDeveloper info: $timelineArgs" + } else { + "" + } + ) + } + else -> errorFormatter.toHumanReadable(asyncRoomSummary.error) + } + } + private fun updateLiveLocationIndicator(isSharingLiveLocation: Boolean) { views.liveLocationStatusIndicator.isVisible = isSharingLiveLocation } diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineViewModel.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineViewModel.kt index 2ab9ce95dd..8a31b6b958 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineViewModel.kt @@ -48,6 +48,7 @@ import im.vector.app.features.call.webrtc.WebRtcCallManager import im.vector.app.features.createdirect.DirectRoomHelper import im.vector.app.features.crypto.keysrequest.OutboundSessionKeySharingStrategy import im.vector.app.features.crypto.verification.SupportedVerificationMethodsProvider +import im.vector.app.features.home.room.detail.error.RoomNotFound import im.vector.app.features.home.room.detail.location.RedactLiveLocationShareEventUseCase import im.vector.app.features.home.room.detail.sticker.StickerPickerActionHandler import im.vector.app.features.home.room.detail.timeline.factory.TimelineFactory @@ -1216,7 +1217,7 @@ class TimelineViewModel @AssistedInject constructor( Timber.w("Warning, room with Id ${initialState.roomId} is not found.") setState { copy( - asyncRoomSummary = Fail(IllegalStateException("Room Not Found")) + asyncRoomSummary = Fail(RoomNotFound()) ) } } else { diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/error/RoomNotFound.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/error/RoomNotFound.kt new file mode 100644 index 0000000000..616f538b37 --- /dev/null +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/error/RoomNotFound.kt @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2022 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package im.vector.app.features.home.room.detail.error + +class RoomNotFound: Throwable() diff --git a/vector/src/main/res/layout/fragment_timeline.xml b/vector/src/main/res/layout/fragment_timeline.xml index d505e23103..f8a31d3281 100644 --- a/vector/src/main/res/layout/fragment_timeline.xml +++ b/vector/src/main/res/layout/fragment_timeline.xml @@ -194,4 +194,47 @@ android:background="?vctr_chat_effect_snow_background" android:visibility="invisible" /> + + + + + + + + + diff --git a/vector/src/main/res/values/strings.xml b/vector/src/main/res/values/strings.xml index 4d39dcae87..8550cee4a8 100644 --- a/vector/src/main/res/values/strings.xml +++ b/vector/src/main/res/values/strings.xml @@ -1349,6 +1349,9 @@ Start the system camera instead of the custom camera screen. To continue you need to accept the Terms of this service. + + Sorry, this room has not been found.\nPlease retry later.%s + You added a new session \'%s\', which is requesting encryption keys. A new session is requesting encryption keys.\nSession name: %1$s\nLast seen: %2$s\nIf you didn’t log in on another session, ignore this request.