Use dispatcher provider instead of hardcoded dispatcher

This commit is contained in:
Maxime NATUREL 2023-02-20 10:22:10 +01:00
parent 27046ed1a6
commit a0bab98af9
2 changed files with 4 additions and 4 deletions

View File

@ -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()
}

View File

@ -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<LocationPreviewViewState, LocationPreviewAction, LocationPreviewViewEvents>(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()
}