Move where the developer options are shown and store them in the app settings.

This commit is contained in:
Stefan Ceriu
2025-04-30 14:01:28 +03:00
committed by Stefan Ceriu
parent eaa6dd9240
commit 0c5be93a75
11 changed files with 65 additions and 39 deletions
@@ -11,6 +11,8 @@ import SwiftUI
typealias SettingsScreenViewModelType = StateStoreViewModelV2<SettingsScreenViewState, SettingsScreenViewAction>
class SettingsScreenViewModel: SettingsScreenViewModelType, SettingsScreenViewModelProtocol {
private let appSettings: AppSettings
private var actionsSubject: PassthroughSubject<SettingsScreenViewModelAction, Never> = .init()
var actions: AnyPublisher<SettingsScreenViewModelAction, Never> {
@@ -18,14 +20,20 @@ class SettingsScreenViewModel: SettingsScreenViewModelType, SettingsScreenViewMo
}
init(userSession: UserSessionProtocol, appSettings: AppSettings, isBugReportServiceEnabled: Bool) {
self.appSettings = appSettings
super.init(initialViewState: .init(deviceID: userSession.clientProxy.deviceID,
userID: userSession.clientProxy.userID,
showAccountDeactivation: userSession.clientProxy.canDeactivateAccount,
showDeveloperOptions: AppSettings.isDevelopmentBuild,
showDeveloperOptions: appSettings.developerOptionsEnabled,
showAnalyticsSettings: appSettings.canPromptForAnalytics,
isBugReportServiceEnabled: isBugReportServiceEnabled),
mediaProvider: userSession.mediaProvider)
appSettings.$developerOptionsEnabled
.weakAssign(to: \.state.showDeveloperOptions, on: self)
.store(in: &cancellables)
userSession.clientProxy.userAvatarURLPublisher
.receive(on: DispatchQueue.main)
.weakAssign(to: \.state.userAvatarURL, on: self)
@@ -105,7 +113,7 @@ class SettingsScreenViewModel: SettingsScreenViewModelType, SettingsScreenViewMo
case .advancedSettings:
actionsSubject.send(.advancedSettings)
case .enableDeveloperOptions:
state.showDeveloperOptions = true
appSettings.developerOptionsEnabled.toggle()
case .developerOptions:
actionsSubject.send(.developerOptions)
case .deactivateAccount: