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)