Allow sending locations within threads

This patch implements support for sending locations within threads by following a similar behavior to the other screens: pass the thread root between the various state machine states until the action is finally invoked.
This commit is contained in:
Stefan Ceriu
2025-06-12 13:30:23 +03:00
committed by Stefan Ceriu
parent 12b56b5b6c
commit 264a68d3e2
9 changed files with 101 additions and 65 deletions

View File

@@ -49,7 +49,7 @@ struct RoomAttachmentPicker: View {
.accessibilityIdentifier(A11yIdentifiers.roomScreen.attachmentPickerPoll)
}
if !context.viewState.isInThread, context.viewState.isLocationSharingEnabled {
if context.viewState.isLocationSharingEnabled {
Button {
context.send(viewAction: .attach(.location))
} label: {

View File

@@ -29,9 +29,9 @@ enum ThreadTimelineScreenCoordinatorAction {
case presentReportContent(itemID: TimelineItemIdentifier, senderID: String)
case presentMediaUploadPicker(MediaPickerScreenSource, threadRootEventID: String?)
case presentMediaUploadPreviewScreen(url: URL, threadRootEventID: String?)
case presentLocationPicker
case presentLocationPicker(threadRootEventID: String?)
case presentLocationViewer(body: String, geoURI: GeoURI, description: String?, threadRootEventID: String?)
case presentPollForm(mode: PollFormMode)
case presentLocationViewer(body: String, geoURI: GeoURI, description: String?)
case presentEmojiPicker(itemID: TimelineItemIdentifier, selectedEmojis: Set<String>)
case presentRoomMemberDetails(userID: String)
case presentMessageForwarding(forwardingItem: MessageForwardingItem)
@@ -99,27 +99,34 @@ final class ThreadTimelineScreenCoordinator: CoordinatorProtocol {
case .displayReportContent(let itemID, let senderID):
actionsSubject.send(.presentReportContent(itemID: itemID, senderID: senderID))
case .displayCameraPicker:
actionsSubject.send(.presentMediaUploadPicker(.camera, threadRootEventID: parameters.timelineController.timelineKind.threadRootEventID))
actionsSubject.send(.presentMediaUploadPicker(.camera,
threadRootEventID: parameters.timelineController.timelineKind.threadRootEventID))
case .displayMediaPicker:
actionsSubject.send(.presentMediaUploadPicker(.photoLibrary, threadRootEventID: parameters.timelineController.timelineKind.threadRootEventID))
actionsSubject.send(.presentMediaUploadPicker(.photoLibrary,
threadRootEventID: parameters.timelineController.timelineKind.threadRootEventID))
case .displayDocumentPicker:
actionsSubject.send(.presentMediaUploadPicker(.documents, threadRootEventID: parameters.timelineController.timelineKind.threadRootEventID))
actionsSubject.send(.presentMediaUploadPicker(.documents,
threadRootEventID: parameters.timelineController.timelineKind.threadRootEventID))
case .displayMediaPreview(let mediaPreviewViewModel):
viewModel.displayMediaPreview(mediaPreviewViewModel)
case .displayLocationPicker:
actionsSubject.send(.presentLocationPicker)
actionsSubject.send(.presentLocationPicker(threadRootEventID: parameters.timelineController.timelineKind.threadRootEventID))
case .displayLocation(let body, let geoURI, let description):
actionsSubject.send(.presentLocationViewer(body: body,
geoURI: geoURI,
description: description, threadRootEventID: parameters.timelineController.timelineKind.threadRootEventID))
case .displayPollForm(let mode):
actionsSubject.send(.presentPollForm(mode: mode))
case .displayMediaUploadPreviewScreen(let url):
actionsSubject.send(.presentMediaUploadPreviewScreen(url: url, threadRootEventID: parameters.timelineController.timelineKind.threadRootEventID))
actionsSubject.send(.presentMediaUploadPreviewScreen(url: url,
threadRootEventID: parameters.timelineController.timelineKind.threadRootEventID))
case .displaySenderDetails(userID: let userID):
actionsSubject.send(.presentRoomMemberDetails(userID: userID))
case .displayMessageForwarding(let forwardingItem):
actionsSubject.send(.presentMessageForwarding(forwardingItem: forwardingItem))
case .displayLocation(let body, let geoURI, let description):
actionsSubject.send(.presentLocationViewer(body: body, geoURI: geoURI, description: description))
case .displayResolveSendFailure(let failure, let sendHandle):
actionsSubject.send(.presentResolveSendFailure(failure: failure, sendHandle: sendHandle))
actionsSubject.send(.presentResolveSendFailure(failure: failure,
sendHandle: sendHandle))
case .hasScrolled, .displayRoom:
break
case .composer(let action):