Remove the threadRootEventID associated value from all the RoomFlowCoordinatorStateMachine states and replace them with a UserInfo passed TimelineController.

This commit is contained in:
Stefan Ceriu
2025-07-22 14:03:08 +03:00
committed by Stefan Ceriu
parent 3fcbc8c60a
commit 1fc15a220d
7 changed files with 108 additions and 81 deletions
@@ -9,12 +9,12 @@ import Combine
import SwiftUI
struct MediaUploadPreviewScreenCoordinatorParameters {
let userIndicatorController: UserIndicatorControllerProtocol
let roomProxy: JoinedRoomProxyProtocol
let timelineController: TimelineControllerProtocol
let userIndicatorController: UserIndicatorControllerProtocol
let mediaUploadingPreprocessor: MediaUploadingPreprocessor
let title: String?
let url: URL
let threadRootEventID: String?
let shouldShowCaptionWarning: Bool
}
@@ -32,12 +32,12 @@ final class MediaUploadPreviewScreenCoordinator: CoordinatorProtocol {
}
init(parameters: MediaUploadPreviewScreenCoordinatorParameters) {
viewModel = MediaUploadPreviewScreenViewModel(userIndicatorController: parameters.userIndicatorController,
roomProxy: parameters.roomProxy,
viewModel = MediaUploadPreviewScreenViewModel(roomProxy: parameters.roomProxy,
timelineController: parameters.timelineController,
userIndicatorController: parameters.userIndicatorController,
mediaUploadingPreprocessor: parameters.mediaUploadingPreprocessor,
title: parameters.title,
url: parameters.url,
threadRootEventID: parameters.threadRootEventID,
shouldShowCaptionWarning: parameters.shouldShowCaptionWarning)
}
@@ -12,11 +12,12 @@ import SwiftUI
typealias MediaUploadPreviewScreenViewModelType = StateStoreViewModelV2<MediaUploadPreviewScreenViewState, MediaUploadPreviewScreenViewAction>
class MediaUploadPreviewScreenViewModel: MediaUploadPreviewScreenViewModelType, MediaUploadPreviewScreenViewModelProtocol {
private let userIndicatorController: UserIndicatorControllerProtocol
private let roomProxy: JoinedRoomProxyProtocol
private let timelineController: TimelineControllerProtocol
private let userIndicatorController: UserIndicatorControllerProtocol
private let mediaUploadingPreprocessor: MediaUploadingPreprocessor
private let url: URL
private let threadRootEventID: String?
private var processingTask: Task<Result<MediaInfo, MediaUploadingPreprocessorError>, Never>
private var requestHandle: SendAttachmentJoinHandleProtocol?
@@ -27,18 +28,18 @@ class MediaUploadPreviewScreenViewModel: MediaUploadPreviewScreenViewModelType,
actionsSubject.eraseToAnyPublisher()
}
init(userIndicatorController: UserIndicatorControllerProtocol,
roomProxy: JoinedRoomProxyProtocol,
init(roomProxy: JoinedRoomProxyProtocol,
timelineController: TimelineControllerProtocol,
userIndicatorController: UserIndicatorControllerProtocol,
mediaUploadingPreprocessor: MediaUploadingPreprocessor,
title: String?,
url: URL,
threadRootEventID: String?,
shouldShowCaptionWarning: Bool) {
self.userIndicatorController = userIndicatorController
self.roomProxy = roomProxy
self.timelineController = timelineController
self.userIndicatorController = userIndicatorController
self.mediaUploadingPreprocessor = mediaUploadingPreprocessor
self.url = url
self.threadRootEventID = threadRootEventID
// Start processing the media whilst the user is reviewing it/adding a caption.
processingTask = Task { await mediaUploadingPreprocessor.processMedia(at: url) }
@@ -227,12 +227,12 @@ struct MediaUploadPreviewScreen_Previews: PreviewProvider, TestablePreview {
static let snapshotURL = URL.picturesDirectory
static let testURL = Bundle.main.url(forResource: "AppIcon60x60@2x", withExtension: "png")
static let viewModel = MediaUploadPreviewScreenViewModel(userIndicatorController: UserIndicatorControllerMock.default,
roomProxy: JoinedRoomProxyMock(.init()),
static let viewModel = MediaUploadPreviewScreenViewModel(roomProxy: JoinedRoomProxyMock(.init()),
timelineController: MockTimelineController(),
userIndicatorController: UserIndicatorControllerMock.default,
mediaUploadingPreprocessor: MediaUploadingPreprocessor(appSettings: ServiceLocator.shared.settings),
title: "App Icon.png",
url: snapshotURL,
threadRootEventID: nil,
shouldShowCaptionWarning: true)
static var previews: some View {
NavigationStack {