Set live as false when live location sharing is times up.
This commit is contained in:
parent
33e735cbdd
commit
137d5e4093
|
@ -1095,20 +1095,7 @@ class TimelineViewModel @AssistedInject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun handleStopLiveLocationSharing() {
|
private fun handleStopLiveLocationSharing() {
|
||||||
viewModelScope.launch {
|
locationSharingServiceConnection.stopLiveLocationSharing(room.roomId)
|
||||||
EventType
|
|
||||||
.STATE_ROOM_BEACON_INFO
|
|
||||||
.mapNotNull {
|
|
||||||
room.getStateEvent(it, QueryStringValue.Equals(session.myUserId))
|
|
||||||
}
|
|
||||||
.firstOrNull()
|
|
||||||
?.let { beaconInfoEvent ->
|
|
||||||
room.stopLiveLocation(beaconInfoEvent)
|
|
||||||
}
|
|
||||||
?.also {
|
|
||||||
locationSharingServiceConnection.stopLiveLocationSharing(room.roomId)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun observeRoomSummary() {
|
private fun observeRoomSummary() {
|
||||||
|
|
|
@ -28,6 +28,7 @@ import im.vector.app.features.notifications.NotificationUtils
|
||||||
import im.vector.app.features.session.coroutineScope
|
import im.vector.app.features.session.coroutineScope
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.parcelize.Parcelize
|
import kotlinx.parcelize.Parcelize
|
||||||
|
import org.matrix.android.sdk.api.query.QueryStringValue
|
||||||
import org.matrix.android.sdk.api.session.Session
|
import org.matrix.android.sdk.api.session.Session
|
||||||
import org.matrix.android.sdk.api.session.events.model.EventType
|
import org.matrix.android.sdk.api.session.events.model.EventType
|
||||||
import org.matrix.android.sdk.api.session.events.model.toContent
|
import org.matrix.android.sdk.api.session.events.model.toContent
|
||||||
|
@ -131,6 +132,10 @@ class LocationSharingService : VectorService(), LocationTracker.Callback {
|
||||||
|
|
||||||
fun stopSharingLocation(roomId: String) {
|
fun stopSharingLocation(roomId: String) {
|
||||||
Timber.i("### LocationSharingService.stopSharingLocation for $roomId")
|
Timber.i("### LocationSharingService.stopSharingLocation for $roomId")
|
||||||
|
|
||||||
|
// Send a new beacon info state by setting live field as false
|
||||||
|
updateStoppedBeaconInfo(roomId)
|
||||||
|
|
||||||
synchronized(roomArgsList) {
|
synchronized(roomArgsList) {
|
||||||
roomArgsList.removeAll { it.roomId == roomId }
|
roomArgsList.removeAll { it.roomId == roomId }
|
||||||
if (roomArgsList.isEmpty()) {
|
if (roomArgsList.isEmpty()) {
|
||||||
|
@ -140,6 +145,25 @@ class LocationSharingService : VectorService(), LocationTracker.Callback {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun updateStoppedBeaconInfo(roomId: String) {
|
||||||
|
activeSessionHolder
|
||||||
|
.getSafeActiveSession()
|
||||||
|
?.let { session ->
|
||||||
|
session.coroutineScope.launch(session.coroutineDispatchers.io) {
|
||||||
|
val room = session.getRoom(roomId)
|
||||||
|
EventType
|
||||||
|
.STATE_ROOM_BEACON_INFO
|
||||||
|
.mapNotNull {
|
||||||
|
room?.getStateEvent(it, QueryStringValue.Equals(session.myUserId))
|
||||||
|
}
|
||||||
|
.firstOrNull()
|
||||||
|
?.let { beaconInfoEvent ->
|
||||||
|
room?.stopLiveLocation(beaconInfoEvent)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun onLocationUpdate(locationData: LocationData) {
|
override fun onLocationUpdate(locationData: LocationData) {
|
||||||
Timber.i("### LocationSharingService.onLocationUpdate. Uncertainty: ${locationData.uncertainty}")
|
Timber.i("### LocationSharingService.onLocationUpdate. Uncertainty: ${locationData.uncertainty}")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue