From fc980570424762329efd1b2bc1ed1d03925eeb78 Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Wed, 15 Jun 2022 14:45:32 +0200 Subject: [PATCH] Forward error to UI in map screen --- .../app/features/home/room/detail/TimelineViewModel.kt | 2 +- .../location/live/map/LocationLiveMapViewEvents.kt | 4 +++- .../location/live/map/LocationLiveMapViewFragment.kt | 10 ++++++++++ .../location/live/map/LocationLiveMapViewModel.kt | 2 +- 4 files changed, 15 insertions(+), 3 deletions(-) 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 99a01211c3..1c2255246b 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 @@ -1294,7 +1294,7 @@ class TimelineViewModel @AssistedInject constructor( } override fun onLocationServiceError(error: Throwable) { - _viewEvents.post(RoomDetailViewEvents.Failure(error)) + _viewEvents.post(RoomDetailViewEvents.Failure(throwable = error, showInDialog = true)) } override fun onCleared() { diff --git a/vector/src/main/java/im/vector/app/features/location/live/map/LocationLiveMapViewEvents.kt b/vector/src/main/java/im/vector/app/features/location/live/map/LocationLiveMapViewEvents.kt index 6645ff58d9..23771299c8 100644 --- a/vector/src/main/java/im/vector/app/features/location/live/map/LocationLiveMapViewEvents.kt +++ b/vector/src/main/java/im/vector/app/features/location/live/map/LocationLiveMapViewEvents.kt @@ -18,4 +18,6 @@ package im.vector.app.features.location.live.map import im.vector.app.core.platform.VectorViewEvents -sealed interface LocationLiveMapViewEvents : VectorViewEvents +sealed interface LocationLiveMapViewEvents : VectorViewEvents { + data class Error(val error: Throwable) : LocationLiveMapViewEvents +} diff --git a/vector/src/main/java/im/vector/app/features/location/live/map/LocationLiveMapViewFragment.kt b/vector/src/main/java/im/vector/app/features/location/live/map/LocationLiveMapViewFragment.kt index 5f2410d697..09522ce4c8 100644 --- a/vector/src/main/java/im/vector/app/features/location/live/map/LocationLiveMapViewFragment.kt +++ b/vector/src/main/java/im/vector/app/features/location/live/map/LocationLiveMapViewFragment.kt @@ -76,6 +76,8 @@ class LocationLiveMapViewFragment @Inject constructor() : VectorBaseFragment + when(viewEvent) { + is LocationLiveMapViewEvents.Error -> displayErrorDialog(viewEvent.error) + } + } + } + override fun onResume() { super.onResume() setupMap() diff --git a/vector/src/main/java/im/vector/app/features/location/live/map/LocationLiveMapViewModel.kt b/vector/src/main/java/im/vector/app/features/location/live/map/LocationLiveMapViewModel.kt index 9ef6449ea0..e89649709a 100644 --- a/vector/src/main/java/im/vector/app/features/location/live/map/LocationLiveMapViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/location/live/map/LocationLiveMapViewModel.kt @@ -82,6 +82,6 @@ class LocationLiveMapViewModel @AssistedInject constructor( } override fun onLocationServiceError(error: Throwable) { - // TODO + _viewEvents.post(LocationLiveMapViewEvents.Error(error)) } }