Recompute location comparison on new user location
This commit is contained in:
parent
125b8d2058
commit
8d1822da96
|
@ -29,6 +29,7 @@ import im.vector.app.features.home.room.detail.timeline.helper.LocationPinProvid
|
||||||
import im.vector.app.features.location.domain.usecase.CompareLocationsUseCase
|
import im.vector.app.features.location.domain.usecase.CompareLocationsUseCase
|
||||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
import kotlinx.coroutines.flow.MutableSharedFlow
|
||||||
import kotlinx.coroutines.flow.distinctUntilChanged
|
import kotlinx.coroutines.flow.distinctUntilChanged
|
||||||
|
import kotlinx.coroutines.flow.lastOrNull
|
||||||
import kotlinx.coroutines.flow.launchIn
|
import kotlinx.coroutines.flow.launchIn
|
||||||
import kotlinx.coroutines.flow.map
|
import kotlinx.coroutines.flow.map
|
||||||
import kotlinx.coroutines.flow.onEach
|
import kotlinx.coroutines.flow.onEach
|
||||||
|
@ -156,10 +157,15 @@ class LocationSharingViewModel @AssistedInject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onLocationUpdate(locationData: LocationData) {
|
override fun onLocationUpdate(locationData: LocationData) {
|
||||||
// TODO compare location with lastTargetLocation => need to save info into the ViewState
|
|
||||||
setState {
|
setState {
|
||||||
copy(lastKnownUserLocation = locationData)
|
copy(lastKnownUserLocation = locationData)
|
||||||
}
|
}
|
||||||
|
viewModelScope.launch {
|
||||||
|
// recompute location comparison using last received target location
|
||||||
|
locationTargetFlow.lastOrNull()?.let {
|
||||||
|
locationTargetFlow.emit(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onLocationProviderIsNotAvailable() {
|
override fun onLocationProviderIsNotAvailable() {
|
||||||
|
|
Loading…
Reference in New Issue