From a0bab98af92f9a07adc255822ae9fb1ba3d54f5a Mon Sep 17 00:00:00 2001 From: Maxime NATUREL <46314705+mnaturel@users.noreply.github.com> Date: Mon, 20 Feb 2023 10:22:10 +0100 Subject: [PATCH] Use dispatcher provider instead of hardcoded dispatcher --- .../features/location/live/map/LiveLocationMapViewModel.kt | 3 +-- .../features/location/preview/LocationPreviewViewModel.kt | 5 +++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/location/live/map/LiveLocationMapViewModel.kt b/vector/src/main/java/im/vector/app/features/location/live/map/LiveLocationMapViewModel.kt index 53e771ee1c..15e41470e0 100644 --- a/vector/src/main/java/im/vector/app/features/location/live/map/LiveLocationMapViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/location/live/map/LiveLocationMapViewModel.kt @@ -27,7 +27,6 @@ import im.vector.app.features.location.LocationData import im.vector.app.features.location.LocationTracker import im.vector.app.features.location.live.StopLiveLocationShareUseCase import im.vector.app.features.location.live.tracking.LocationSharingServiceConnection -import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.launch @@ -132,7 +131,7 @@ class LiveLocationMapViewModel @AssistedInject constructor( setState { copy(isLoadingUserLocation = true) } - viewModelScope.launch(Dispatchers.Main) { + viewModelScope.launch(session.coroutineDispatchers.main) { locationTracker.start() locationTracker.requestLastKnownLocation() } diff --git a/vector/src/main/java/im/vector/app/features/location/preview/LocationPreviewViewModel.kt b/vector/src/main/java/im/vector/app/features/location/preview/LocationPreviewViewModel.kt index 3822d9e9ee..a1544ac2af 100644 --- a/vector/src/main/java/im/vector/app/features/location/preview/LocationPreviewViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/location/preview/LocationPreviewViewModel.kt @@ -26,13 +26,14 @@ import im.vector.app.core.platform.VectorViewModel import im.vector.app.features.home.room.detail.timeline.helper.LocationPinProvider import im.vector.app.features.location.LocationData import im.vector.app.features.location.LocationTracker -import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.launch +import org.matrix.android.sdk.api.session.Session class LocationPreviewViewModel @AssistedInject constructor( @Assisted private val initialState: LocationPreviewViewState, + private val session: Session, private val locationPinProvider: LocationPinProvider, private val locationTracker: LocationTracker, ) : VectorViewModel(initialState), LocationTracker.Callback { @@ -83,7 +84,7 @@ class LocationPreviewViewModel @AssistedInject constructor( setState { copy(isLoadingUserLocation = true) } - viewModelScope.launch(Dispatchers.Main) { + viewModelScope.launch(session.coroutineDispatchers.main) { locationTracker.start() locationTracker.requestLastKnownLocation() }