Files
letro-ios/ElementX/Sources/Screens/Settings/AvancedOptionsScreen/AdvancedSettingsScreenViewModel.swift
Doug a141adbd1f Enable the Optimised Media Uploads feature. (#3467)
* Enable the Optimised Media Uploads feature.

(Well move the toggle from Developer Options to Advanced Settings)

* Add OptimizeMediaUploads analytics.

* Final strings.

* Upload reduced quality media by default 😢

Move the setting out of the feature flags section in the file.

* Fix unit tests now the default has changed.

* Pull in updated string, fix snapshots.
2024-10-31 14:14:14 +00:00

31 lines
1.2 KiB
Swift

//
// Copyright 2022-2024 New Vector Ltd.
//
// SPDX-License-Identifier: AGPL-3.0-only
// Please see LICENSE in the repository root for full details.
//
import Combine
import SwiftUI
typealias AdvancedSettingsScreenViewModelType = StateStoreViewModel<AdvancedSettingsScreenViewState, AdvancedSettingsScreenViewAction>
class AdvancedSettingsScreenViewModel: AdvancedSettingsScreenViewModelType, AdvancedSettingsScreenViewModelProtocol {
private let analytics: AnalyticsService
init(advancedSettings: AdvancedSettingsProtocol, analytics: AnalyticsService) {
self.analytics = analytics
let state = AdvancedSettingsScreenViewState(bindings: .init(advancedSettings: advancedSettings))
super.init(initialViewState: state)
}
override func process(viewAction: AdvancedSettingsScreenViewAction) {
switch viewAction {
case .optimizeMediaUploadsChanged:
// Note: Using a view action here as sinking the AppSettings publisher tracks the initial value.
analytics.trackInteraction(name: state.bindings.optimizeMediaUploads ? .MobileSettingsOptimizeMediaUploadsEnabled : .MobileSettingsOptimizeMediaUploadsDisabled)
}
}
}