Switch callbacks to combine (#1710)

* #750 - Convert the SoftLogoutScreen to combine

* #750 - Convert the UserSessionFlowCoordinator to Combine

* #750 - Convert the AnalyticsPromptScreen to Combine

* #750 - Convert the LoginScreen to Combine

* #750 - Convert the ServerSelectionScreen to Combine

* #750 - Convert the EmojiPickerScreen to Combine

* #750 - Convert the HomeScreen to Combine

* #750 - Convert the MediaUploadPreviewScreen to Combine

* #750 - Convert the OnboardingScreen to Combine

* Rename `Onboarding` to `OnboardingScreen`

* #750 - Convert the ReportContentScreen to Combine

* #750 - Convert the RoomDetailsSscreen to Combine

* #750 - Convert the RoomMemberDetailsScreen to Combine

* #750 - Convert the RoomMembersListScreen to Combine

* #750 - Convert the SessionVerificationScreen to Combine

* #750 - Convert the SettingsScreen to Combine

* #750 - Convert the AdvancedSettingsScreen to Combine

* #750 - Convert the DeveloperOptionsScreen to Combine

* Fix the unit tests

* Use .sink action and the same cancellables constructor everywhere

* Cleanup cancellables when setting up tests
This commit is contained in:
Stefan Ceriu
2023-09-14 12:53:33 +03:00
committed by GitHub
parent a0d40b6f0c
commit a4e5e4f0ed
89 changed files with 884 additions and 589 deletions
@@ -32,9 +32,12 @@ enum ReportContentScreenCoordinatorAction {
final class ReportContentScreenCoordinator: CoordinatorProtocol {
private let parameters: ReportContentScreenCoordinatorParameters
private var viewModel: ReportContentScreenViewModelProtocol
private var cancellables: Set<AnyCancellable> = .init()
private let actionsSubject: PassthroughSubject<ReportContentScreenCoordinatorAction, Never> = .init()
private var cancellables = Set<AnyCancellable>()
var callback: ((ReportContentScreenCoordinatorAction) -> Void)?
var actions: AnyPublisher<ReportContentScreenCoordinatorAction, Never> {
actionsSubject.eraseToAnyPublisher()
}
init(parameters: ReportContentScreenCoordinatorParameters) {
self.parameters = parameters
@@ -48,17 +51,18 @@ final class ReportContentScreenCoordinator: CoordinatorProtocol {
viewModel.actions
.sink { [weak self] action in
guard let self else { return }
switch action {
case .submitStarted:
self.startLoading()
startLoading()
case let .submitFailed(error):
self.stopLoading()
self.showError(description: error.localizedDescription)
stopLoading()
showError(description: error.localizedDescription)
case .submitFinished:
self.stopLoading()
self.callback?(.finish)
stopLoading()
actionsSubject.send(.finish)
case .cancel:
self.callback?(.cancel)
actionsSubject.send(.cancel)
}
}
.store(in: &cancellables)