mirror of
https://github.com/element-hq/element-android
synced 2024-11-28 05:31:21 +03:00
Set live as false when live location sharing is times up.
This commit is contained in:
parent
33e735cbdd
commit
137d5e4093
2 changed files with 25 additions and 14 deletions
|
@ -1095,20 +1095,7 @@ class TimelineViewModel @AssistedInject constructor(
|
|||
}
|
||||
|
||||
private fun handleStopLiveLocationSharing() {
|
||||
viewModelScope.launch {
|
||||
EventType
|
||||
.STATE_ROOM_BEACON_INFO
|
||||
.mapNotNull {
|
||||
room.getStateEvent(it, QueryStringValue.Equals(session.myUserId))
|
||||
}
|
||||
.firstOrNull()
|
||||
?.let { beaconInfoEvent ->
|
||||
room.stopLiveLocation(beaconInfoEvent)
|
||||
}
|
||||
?.also {
|
||||
locationSharingServiceConnection.stopLiveLocationSharing(room.roomId)
|
||||
}
|
||||
}
|
||||
locationSharingServiceConnection.stopLiveLocationSharing(room.roomId)
|
||||
}
|
||||
|
||||
private fun observeRoomSummary() {
|
||||
|
|
|
@ -28,6 +28,7 @@ import im.vector.app.features.notifications.NotificationUtils
|
|||
import im.vector.app.features.session.coroutineScope
|
||||
import kotlinx.coroutines.launch
|
||||
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.events.model.EventType
|
||||
import org.matrix.android.sdk.api.session.events.model.toContent
|
||||
|
@ -131,6 +132,10 @@ class LocationSharingService : VectorService(), LocationTracker.Callback {
|
|||
|
||||
fun stopSharingLocation(roomId: String) {
|
||||
Timber.i("### LocationSharingService.stopSharingLocation for $roomId")
|
||||
|
||||
// Send a new beacon info state by setting live field as false
|
||||
updateStoppedBeaconInfo(roomId)
|
||||
|
||||
synchronized(roomArgsList) {
|
||||
roomArgsList.removeAll { it.roomId == roomId }
|
||||
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) {
|
||||
Timber.i("### LocationSharingService.onLocationUpdate. Uncertainty: ${locationData.uncertainty}")
|
||||
|
||||
|
|
Loading…
Reference in a new issue