Display an error message when the room is not known.
This commit is contained in:
parent
f56f4e1160
commit
1ced47fbd2
@ -62,6 +62,7 @@ import com.airbnb.epoxy.EpoxyModel
|
|||||||
import com.airbnb.epoxy.OnModelBuildFinishedListener
|
import com.airbnb.epoxy.OnModelBuildFinishedListener
|
||||||
import com.airbnb.epoxy.addGlidePreloader
|
import com.airbnb.epoxy.addGlidePreloader
|
||||||
import com.airbnb.epoxy.glidePreloader
|
import com.airbnb.epoxy.glidePreloader
|
||||||
|
import com.airbnb.mvrx.Fail
|
||||||
import com.airbnb.mvrx.args
|
import com.airbnb.mvrx.args
|
||||||
import com.airbnb.mvrx.fragmentViewModel
|
import com.airbnb.mvrx.fragmentViewModel
|
||||||
import com.airbnb.mvrx.withState
|
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.boolean
|
||||||
import im.vector.app.features.home.room.detail.composer.voice.VoiceMessageRecorderView
|
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.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.readreceipts.DisplayReadReceiptsBottomSheet
|
||||||
import im.vector.app.features.home.room.detail.timeline.TimelineEventController
|
import im.vector.app.features.home.room.detail.timeline.TimelineEventController
|
||||||
import im.vector.app.features.home.room.detail.timeline.action.EventSharedAction
|
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 ->
|
override fun invalidate() = withState(timelineViewModel, messageComposerViewModel) { mainState, messageComposerState ->
|
||||||
invalidateOptionsMenu()
|
invalidateOptionsMenu()
|
||||||
|
if (mainState.asyncRoomSummary is Fail) {
|
||||||
|
handleRoomSummaryFailure(mainState.asyncRoomSummary)
|
||||||
|
return@withState
|
||||||
|
}
|
||||||
val summary = mainState.asyncRoomSummary()
|
val summary = mainState.asyncRoomSummary()
|
||||||
renderToolbar(summary)
|
renderToolbar(summary)
|
||||||
renderTypingMessageNotification(summary, mainState)
|
renderTypingMessageNotification(summary, mainState)
|
||||||
@ -1695,6 +1701,23 @@ class TimelineFragment :
|
|||||||
updateLiveLocationIndicator(mainState.isSharingLiveLocation)
|
updateLiveLocationIndicator(mainState.isSharingLiveLocation)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun handleRoomSummaryFailure(asyncRoomSummary: Fail<RoomSummary>) {
|
||||||
|
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) {
|
private fun updateLiveLocationIndicator(isSharingLiveLocation: Boolean) {
|
||||||
views.liveLocationStatusIndicator.isVisible = isSharingLiveLocation
|
views.liveLocationStatusIndicator.isVisible = isSharingLiveLocation
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,7 @@ import im.vector.app.features.call.webrtc.WebRtcCallManager
|
|||||||
import im.vector.app.features.createdirect.DirectRoomHelper
|
import im.vector.app.features.createdirect.DirectRoomHelper
|
||||||
import im.vector.app.features.crypto.keysrequest.OutboundSessionKeySharingStrategy
|
import im.vector.app.features.crypto.keysrequest.OutboundSessionKeySharingStrategy
|
||||||
import im.vector.app.features.crypto.verification.SupportedVerificationMethodsProvider
|
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.location.RedactLiveLocationShareEventUseCase
|
||||||
import im.vector.app.features.home.room.detail.sticker.StickerPickerActionHandler
|
import im.vector.app.features.home.room.detail.sticker.StickerPickerActionHandler
|
||||||
import im.vector.app.features.home.room.detail.timeline.factory.TimelineFactory
|
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.")
|
Timber.w("Warning, room with Id ${initialState.roomId} is not found.")
|
||||||
setState {
|
setState {
|
||||||
copy(
|
copy(
|
||||||
asyncRoomSummary = Fail(IllegalStateException("Room Not Found"))
|
asyncRoomSummary = Fail(RoomNotFound())
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -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()
|
@ -194,4 +194,47 @@
|
|||||||
android:background="?vctr_chat_effect_snow_background"
|
android:background="?vctr_chat_effect_snow_background"
|
||||||
android:visibility="invisible" />
|
android:visibility="invisible" />
|
||||||
|
|
||||||
|
<!-- Room not found layout -->
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
android:id="@+id/roomNotFound"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:background="?android:colorBackground"
|
||||||
|
android:elevation="10dp"
|
||||||
|
android:visibility="gone"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
tools:visibility="gone">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/roomNotFoundIcon"
|
||||||
|
android:layout_width="60dp"
|
||||||
|
android:layout_height="60dp"
|
||||||
|
android:importantForAccessibility="no"
|
||||||
|
android:src="@drawable/ic_alert_triangle"
|
||||||
|
app:layout_constraintBottom_toTopOf="@id/roomNotFoundText"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintVertical_chainStyle="packed" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/roomNotFoundText"
|
||||||
|
style="@style/Widget.Vector.TextView.Subtitle"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="@dimen/layout_vertical_margin"
|
||||||
|
android:gravity="center"
|
||||||
|
android:paddingHorizontal="16dp"
|
||||||
|
android:text="@string/timeline_error_room_not_found"
|
||||||
|
android:textColor="?vctr_content_primary"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/roomNotFoundIcon" />
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
@ -1349,6 +1349,9 @@
|
|||||||
<string name="settings_labs_native_camera_summary">Start the system camera instead of the custom camera screen.</string>
|
<string name="settings_labs_native_camera_summary">Start the system camera instead of the custom camera screen.</string>
|
||||||
<string name="widget_integration_review_terms">To continue you need to accept the Terms of this service.</string>
|
<string name="widget_integration_review_terms">To continue you need to accept the Terms of this service.</string>
|
||||||
|
|
||||||
|
<!-- Room not found. %s will contain some debug info in developer mode. -->
|
||||||
|
<string name="timeline_error_room_not_found">Sorry, this room has not been found.\nPlease retry later.%s</string>
|
||||||
|
|
||||||
<!-- share keys -->
|
<!-- share keys -->
|
||||||
<string name="you_added_a_new_device">You added a new session \'%s\', which is requesting encryption keys.</string>
|
<string name="you_added_a_new_device">You added a new session \'%s\', which is requesting encryption keys.</string>
|
||||||
<string name="you_added_a_new_device_with_info">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.</string>
|
<string name="you_added_a_new_device_with_info">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.</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user