From a5054f506a662b96fc066d94c47066fab9444c28 Mon Sep 17 00:00:00 2001 From: Mauro Romito Date: Thu, 2 Apr 2026 21:54:09 +0200 Subject: [PATCH] implement the stop action in the `LiveLocationRoomTimelineView` --- ElementX/Sources/Screens/Timeline/TimelineModels.swift | 2 ++ ElementX/Sources/Screens/Timeline/TimelineViewModel.swift | 2 ++ .../View/TimelineItemViews/LiveLocationRoomTimelineView.swift | 4 +++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ElementX/Sources/Screens/Timeline/TimelineModels.swift b/ElementX/Sources/Screens/Timeline/TimelineModels.swift index ed93d5195..8083e95d1 100644 --- a/ElementX/Sources/Screens/Timeline/TimelineModels.swift +++ b/ElementX/Sources/Screens/Timeline/TimelineModels.swift @@ -70,6 +70,8 @@ enum TimelineViewAction { case handlePollAction(TimelineViewPollAction) case handleAudioPlayerAction(TimelineAudioPlayerAction) + case stopLiveLocationSharing + /// Focus the timeline onto the specified event ID (switching to a detached timeline if needed). case focusOnEventID(String) /// Switch back to a live timeline (from a detached one). diff --git a/ElementX/Sources/Screens/Timeline/TimelineViewModel.swift b/ElementX/Sources/Screens/Timeline/TimelineViewModel.swift index a379a7554..439a1d2d2 100644 --- a/ElementX/Sources/Screens/Timeline/TimelineViewModel.swift +++ b/ElementX/Sources/Screens/Timeline/TimelineViewModel.swift @@ -199,6 +199,8 @@ class TimelineViewModel: TimelineViewModelType, TimelineViewModelProtocol { handlePollAction(pollAction) case .handleAudioPlayerAction(let audioPlayerAction): handleAudioPlayerAction(audioPlayerAction) + case .stopLiveLocationSharing: + Task { await userSession.liveLocationManager.stopLiveLocation(roomID: state.roomID) } case .focusOnEventID(let eventID): Task { await focusOnEvent(eventID: eventID) } case .focusLive: diff --git a/ElementX/Sources/Screens/Timeline/View/TimelineItemViews/LiveLocationRoomTimelineView.swift b/ElementX/Sources/Screens/Timeline/View/TimelineItemViews/LiveLocationRoomTimelineView.swift index f8f764638..2ff83e778 100644 --- a/ElementX/Sources/Screens/Timeline/View/TimelineItemViews/LiveLocationRoomTimelineView.swift +++ b/ElementX/Sources/Screens/Timeline/View/TimelineItemViews/LiveLocationRoomTimelineView.swift @@ -173,7 +173,9 @@ struct LiveLocationRoomTimelineView: View { Spacer() if isLive, timelineItem.isOutgoing { - Button { } label: { + Button { + context?.send(viewAction: .stopLiveLocationSharing) + } label: { CompoundIcon(\.stop, size: .small, relativeTo: .compound.bodySMSemibold) .foregroundStyle(.compound.iconOnSolidPrimary) .padding(5)