mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 12:07:55 +00:00
fccad5fc30
Remove some redundant injections when passed alongside a user session too. # Conflicts: # ElementX/Sources/Screens/PinnedEventsTimelineScreen/View/PinnedEventsTimelineScreen.swift # ElementX/Sources/Screens/Timeline/TimelineViewModel.swift
59 lines
2.0 KiB
Swift
59 lines
2.0 KiB
Swift
//
|
|
// Copyright 2026 Element Creations Ltd.
|
|
//
|
|
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
|
|
// Please see LICENSE files in the repository root for full details.
|
|
//
|
|
|
|
import Combine
|
|
import SwiftUI
|
|
|
|
struct SearchScreenCoordinatorParameters {
|
|
let roomSummaryProvider: RoomSummaryProviderProtocol
|
|
let clientProxy: ClientProxyProtocol
|
|
let mediaProvider: MediaProviderProtocol
|
|
let userIndicatorController: UserIndicatorControllerProtocol
|
|
let userSettings: UserSettings
|
|
}
|
|
|
|
enum SearchScreenCoordinatorAction {
|
|
case presentRoom(roomID: String, eventID: String?)
|
|
case cancel
|
|
}
|
|
|
|
final class SearchScreenCoordinator: CoordinatorProtocol {
|
|
private let viewModel: SearchScreenViewModelProtocol
|
|
|
|
private var cancellables = Set<AnyCancellable>()
|
|
|
|
private let actionsSubject: PassthroughSubject<SearchScreenCoordinatorAction, Never> = .init()
|
|
var actionsPublisher: AnyPublisher<SearchScreenCoordinatorAction, Never> {
|
|
actionsSubject.eraseToAnyPublisher()
|
|
}
|
|
|
|
init(parameters: SearchScreenCoordinatorParameters) {
|
|
viewModel = SearchScreenViewModel(roomSummaryProvider: parameters.roomSummaryProvider,
|
|
clientProxy: parameters.clientProxy,
|
|
mediaProvider: parameters.mediaProvider,
|
|
userIndicatorController: parameters.userIndicatorController,
|
|
userSettings: parameters.userSettings)
|
|
}
|
|
|
|
func start() {
|
|
viewModel.actionsPublisher.sink { [weak self] action in
|
|
guard let self else { return }
|
|
switch action {
|
|
case .presentRoom(let roomID, let eventID):
|
|
actionsSubject.send(.presentRoom(roomID: roomID, eventID: eventID))
|
|
case .cancel:
|
|
actionsSubject.send(.cancel)
|
|
}
|
|
}
|
|
.store(in: &cancellables)
|
|
}
|
|
|
|
func toPresentable() -> AnyView {
|
|
AnyView(SearchScreen(context: viewModel.context))
|
|
}
|
|
}
|