mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
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.
This commit is contained in:
+7
-2
@@ -8,11 +8,16 @@
|
||||
import Combine
|
||||
import SwiftUI
|
||||
|
||||
struct AdvancedSettingsScreenCoordinatorParameters {
|
||||
let appSettings: AppSettings
|
||||
let analytics: AnalyticsService
|
||||
}
|
||||
|
||||
final class AdvancedSettingsScreenCoordinator: CoordinatorProtocol {
|
||||
private var viewModel: AdvancedSettingsScreenViewModelProtocol
|
||||
|
||||
init() {
|
||||
viewModel = AdvancedSettingsScreenViewModel(advancedSettings: ServiceLocator.shared.settings)
|
||||
init(parameters: AdvancedSettingsScreenCoordinatorParameters) {
|
||||
viewModel = AdvancedSettingsScreenViewModel(advancedSettings: parameters.appSettings, analytics: parameters.analytics)
|
||||
}
|
||||
|
||||
func toPresentable() -> AnyView {
|
||||
|
||||
+5
-1
@@ -26,12 +26,16 @@ struct AdvancedSettingsScreenViewStateBindings {
|
||||
}
|
||||
}
|
||||
|
||||
enum AdvancedSettingsScreenViewAction { }
|
||||
enum AdvancedSettingsScreenViewAction {
|
||||
case optimizeMediaUploadsChanged
|
||||
}
|
||||
|
||||
protocol AdvancedSettingsProtocol: AnyObject {
|
||||
var viewSourceEnabled: Bool { get set }
|
||||
var appAppearance: AppAppearance { get set }
|
||||
var sharePresence: Bool { get set }
|
||||
|
||||
var optimizeMediaUploads: Bool { get set }
|
||||
}
|
||||
|
||||
extension AppSettings: AdvancedSettingsProtocol { }
|
||||
|
||||
+12
-4
@@ -11,12 +11,20 @@ import SwiftUI
|
||||
typealias AdvancedSettingsScreenViewModelType = StateStoreViewModel<AdvancedSettingsScreenViewState, AdvancedSettingsScreenViewAction>
|
||||
|
||||
class AdvancedSettingsScreenViewModel: AdvancedSettingsScreenViewModelType, AdvancedSettingsScreenViewModelProtocol {
|
||||
init(advancedSettings: AdvancedSettingsProtocol) {
|
||||
let bindings = AdvancedSettingsScreenViewStateBindings(advancedSettings: advancedSettings)
|
||||
let state = AdvancedSettingsScreenViewState(bindings: bindings)
|
||||
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) { }
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+11
-2
@@ -18,12 +18,20 @@ struct AdvancedSettingsScreen: View {
|
||||
kind: .picker(selection: $context.appAppearance,
|
||||
items: AppAppearance.allCases.map { (title: $0.name, tag: $0) }))
|
||||
|
||||
ListRow(label: .plain(title: L10n.actionViewSource),
|
||||
ListRow(label: .plain(title: L10n.actionViewSource,
|
||||
description: L10n.screenAdvancedSettingsViewSourceDescription),
|
||||
kind: .toggle($context.viewSourceEnabled))
|
||||
|
||||
ListRow(label: .plain(title: L10n.screenAdvancedSettingsSharePresence,
|
||||
description: L10n.screenAdvancedSettingsSharePresenceDescription),
|
||||
kind: .toggle($context.sharePresence))
|
||||
|
||||
ListRow(label: .plain(title: L10n.screenAdvancedSettingsMediaCompressionTitle,
|
||||
description: L10n.screenAdvancedSettingsMediaCompressionDescription),
|
||||
kind: .toggle($context.optimizeMediaUploads))
|
||||
.onChange(of: context.optimizeMediaUploads) {
|
||||
context.send(viewAction: .optimizeMediaUploadsChanged)
|
||||
}
|
||||
}
|
||||
}
|
||||
.compoundList()
|
||||
@@ -48,7 +56,8 @@ private extension AppAppearance {
|
||||
// MARK: - Previews
|
||||
|
||||
struct AdvancedSettingsScreen_Previews: PreviewProvider, TestablePreview {
|
||||
static let viewModel = AdvancedSettingsScreenViewModel(advancedSettings: ServiceLocator.shared.settings)
|
||||
static let viewModel = AdvancedSettingsScreenViewModel(advancedSettings: ServiceLocator.shared.settings,
|
||||
analytics: ServiceLocator.shared.analytics)
|
||||
static var previews: some View {
|
||||
NavigationStack {
|
||||
AdvancedSettingsScreen(context: viewModel.context)
|
||||
|
||||
-1
@@ -46,7 +46,6 @@ protocol DeveloperOptionsProtocol: AnyObject {
|
||||
var hideUnreadMessagesBadge: Bool { get set }
|
||||
var fuzzyRoomListSearchEnabled: Bool { get set }
|
||||
var hideTimelineMedia: Bool { get set }
|
||||
var optimizeMediaUploads: Bool { get set }
|
||||
var enableOnlySignedDeviceIsolationMode: Bool { get set }
|
||||
var elementCallBaseURLOverride: URL? { get set }
|
||||
var knockingEnabled: Bool { get set }
|
||||
|
||||
-6
@@ -62,12 +62,6 @@ struct DeveloperOptionsScreen: View {
|
||||
}
|
||||
}
|
||||
|
||||
Section("Media") {
|
||||
Toggle(isOn: $context.optimizeMediaUploads) {
|
||||
Text("Optimise for upload")
|
||||
}
|
||||
}
|
||||
|
||||
Section {
|
||||
Toggle(isOn: $context.enableOnlySignedDeviceIsolationMode) {
|
||||
Text("Exclude insecure devices when sending/receiving messages")
|
||||
|
||||
Reference in New Issue
Block a user