* Use StateStoreViewModelV2 in AnalyticsPromptScreen.
* Use StateStoreViewModelV2 in UserProfileScreen.
* Use StateStoreViewModelV2 in MediaUploadPreviewScreen.
* Use StateStoreViewModelV2 in the Roles & Permissions screens.
* Add the asyncStream variant of deferFailure.
* Use StateStoreViewModelV2 in BlockedUsersScreen.
* Use StateStoreViewModelV2 in ManageRoomMemberSheet.
* Use StateStoreViewModelV2 in ResolveVerifiedUserSendFailureScreen.
* Use StateStoreViewModelV2 in ReportContentScreen.
* Use StateStoreViewModelV2 in ReportRoomScreen.
* Use StateStoreViewModelV2 in StaticLocationScreen.
* Use StateStoreViewModelV2 in EmojiPickerScreen.
* Use StateStoreViewModelV2 in PollFormScreen.
* Use StateStoreViewModelV2 in DeclineAndBlockScreen.
* Use StateStoreViewModelV2 in RoomDetailsScreen.
* Fix a random compilation error that just popped up 🤷♂️
* Fix expectation message.
37 lines
1.3 KiB
Swift
37 lines
1.3 KiB
Swift
//
|
|
// Copyright 2021-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
|
|
|
|
typealias AnalyticsPromptScreenViewModelType = StateStoreViewModelV2<AnalyticsPromptScreenViewState, AnalyticsPromptScreenViewAction>
|
|
|
|
class AnalyticsPromptScreenViewModel: AnalyticsPromptScreenViewModelType, AnalyticsPromptScreenViewModelProtocol {
|
|
private var actionsSubject: PassthroughSubject<AnalyticsPromptScreenViewModelAction, Never> = .init()
|
|
|
|
var actions: AnyPublisher<AnalyticsPromptScreenViewModelAction, Never> {
|
|
actionsSubject.eraseToAnyPublisher()
|
|
}
|
|
|
|
/// Initialize a view model with the specified prompt type and app display name.
|
|
init(termsURL: URL?) {
|
|
let promptStrings = AnalyticsPromptScreenStrings(termsURL: termsURL)
|
|
super.init(initialViewState: AnalyticsPromptScreenViewState(strings: promptStrings))
|
|
}
|
|
|
|
// MARK: - Public
|
|
|
|
override func process(viewAction: AnalyticsPromptScreenViewAction) {
|
|
switch viewAction {
|
|
case .enable:
|
|
actionsSubject.send(.enable)
|
|
case .disable:
|
|
actionsSubject.send(.disable)
|
|
}
|
|
}
|
|
}
|