mirror of
https://github.com/element-hq/element-android
synced 2024-11-27 11:59:12 +03:00
Recompute location comparison on new user location
This commit is contained in:
parent
125b8d2058
commit
8d1822da96
1 changed files with 7 additions and 1 deletions
|
@ -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 kotlinx.coroutines.flow.MutableSharedFlow
|
||||
import kotlinx.coroutines.flow.distinctUntilChanged
|
||||
import kotlinx.coroutines.flow.lastOrNull
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
|
@ -156,10 +157,15 @@ class LocationSharingViewModel @AssistedInject constructor(
|
|||
}
|
||||
|
||||
override fun onLocationUpdate(locationData: LocationData) {
|
||||
// TODO compare location with lastTargetLocation => need to save info into the ViewState
|
||||
setState {
|
||||
copy(lastKnownUserLocation = locationData)
|
||||
}
|
||||
viewModelScope.launch {
|
||||
// recompute location comparison using last received target location
|
||||
locationTargetFlow.lastOrNull()?.let {
|
||||
locationTargetFlow.emit(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onLocationProviderIsNotAvailable() {
|
||||
|
|
Loading…
Reference in a new issue