Live Location Sharing - handle server echoes (#5514)

* Track active live location sessions by ID instead of timeout.

# Conflicts:
#	ElementX/Sources/Services/Location/LiveLocationManager.swift

* implemented a system to promote starting session to active sesessions to send locations at the right time, and a system to remove a local session if it's handled by an external device.

* pr suggestions

---------

Co-authored-by: Doug <douglase@element.io>
This commit is contained in:
Mauro
2026-04-30 15:18:36 +02:00
committed by GitHub
parent 53a54c1b90
commit 76f744b9c4
13 changed files with 209 additions and 61 deletions
@@ -46,6 +46,9 @@ class ClientProxy: ClientProxyProtocol {
// periphery:ignore - required for instance retention in the rust codebase
private var mediaPreviewConfigListenerTaskHandle: TaskHandle?
// periphery:ignore - required for instance retention in the rust codebase
private var liveLocationOwnInfoUpdatesListenerTaskHandle: TaskHandle?
private var delegateHandle: TaskHandle?
@@ -188,7 +191,12 @@ class ClientProxy: ClientProxyProtocol {
}
var roomsToAwait: Set<String> = []
private let liveLocationOwnInfoUpdatesSubject = PassthroughSubject<LiveLocationOwnInfoUpdate, Never>()
var liveLocationOwnInfoUpdatesPublisher: AnyPublisher<LiveLocationOwnInfoUpdate, Never> {
liveLocationOwnInfoUpdatesSubject.eraseToAnyPublisher()
}
private let sendQueueStatusSubject = CurrentValueSubject<Bool, Never>(false)
init(client: ClientProtocol,
@@ -270,6 +278,8 @@ class ClientProxy: ClientProxyProtocol {
Task {
mediaPreviewConfigListenerTaskHandle = await createMediaPreviewConfigObserver()
}
liveLocationOwnInfoUpdatesListenerTaskHandle = createLiveLocationOwnInfoUpdatesObserver()
}
var userID: String {
@@ -1136,6 +1146,21 @@ class ClientProxy: ClientProxyProtocol {
}
}
private func createLiveLocationOwnInfoUpdatesObserver() -> TaskHandle? {
do {
return try client.subscribeToOwnBeaconInfoUpdates(listener: SDKListener { [weak self] update in
guard let self else { return }
let appUpdate = LiveLocationOwnInfoUpdate(roomID: update.roomId,
eventID: update.eventId,
isLive: update.live)
liveLocationOwnInfoUpdatesSubject.send(appUpdate)
})
} catch {
MXLog.error("Failed creating own beacon info updates observer: \(error)")
return nil
}
}
private func createRoomListServiceObserver(_ roomListService: RoomListService) -> TaskHandle {
roomListService.state(listener: SDKListener { [weak self] state in
guard let self else { return }