Files
element-x-ios/ElementX/Sources/Screens/RoomSelectionScreen/RoomSelectionScreenCoordinator.swift
T
Mauro 319441d527 Use a static room summary provider to resolve room summaries through id and aliases (#3863)
* trying to debug why sometimes the value

is missing even if it appears in the room list

* static room provider implementation

* set the page size through the init

* removed reset filters on .cancel

since using the sop function is safer
2025-03-04 14:08:15 +01:00

57 lines
1.8 KiB
Swift

//
// Copyright 2022-2024 New Vector 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 RoomSelectionScreenCoordinatorParameters {
let clientProxy: ClientProxyProtocol
let roomSummaryProvider: RoomSummaryProviderProtocol
let mediaProvider: MediaProviderProtocol
}
enum RoomSelectionScreenCoordinatorAction {
case dismiss
case confirm(roomID: String)
}
final class RoomSelectionScreenCoordinator: CoordinatorProtocol {
private var viewModel: RoomSelectionScreenViewModelProtocol
private let actionsSubject: PassthroughSubject<RoomSelectionScreenCoordinatorAction, Never> = .init()
private var cancellables = Set<AnyCancellable>()
var actionsPublisher: AnyPublisher<RoomSelectionScreenCoordinatorAction, Never> {
actionsSubject.eraseToAnyPublisher()
}
init(parameters: RoomSelectionScreenCoordinatorParameters) {
viewModel = RoomSelectionScreenViewModel(clientProxy: parameters.clientProxy,
roomSummaryProvider: parameters.roomSummaryProvider,
mediaProvider: parameters.mediaProvider)
}
func start() {
viewModel.actionsPublisher.sink { [weak self] action in
switch action {
case .dismiss:
self?.actionsSubject.send(.dismiss)
case .confirm(let roomID):
self?.actionsSubject.send(.confirm(roomID: roomID))
}
}
.store(in: &cancellables)
}
func stop() {
viewModel.stop()
}
func toPresentable() -> AnyView {
AnyView(RoomSelectionScreen(context: viewModel.context))
}
}