mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
37 lines
1.2 KiB
Swift
37 lines
1.2 KiB
Swift
import Foundation
|
|
import TelegramCore
|
|
import SwiftSignalKit
|
|
|
|
public struct ExperimentalSettings: Codable, Equatable {
|
|
public static var defaultSettings: ExperimentalSettings {
|
|
return ExperimentalSettings()
|
|
}
|
|
|
|
public init() {
|
|
}
|
|
|
|
public init(from decoder: Decoder) throws {
|
|
}
|
|
|
|
public func encode(to encoder: Encoder) throws {
|
|
}
|
|
|
|
public static func ==(lhs: ExperimentalSettings, rhs: ExperimentalSettings) -> Bool {
|
|
return true
|
|
}
|
|
}
|
|
|
|
public func updateExperimentalSettingsInteractively(accountManager: AccountManager<TelegramAccountManagerTypes>, _ f: @escaping (ExperimentalSettings) -> ExperimentalSettings) -> Signal<Void, NoError> {
|
|
return accountManager.transaction { transaction -> Void in
|
|
transaction.updateSharedData(ApplicationSpecificSharedDataKeys.experimentalSettings, { entry in
|
|
let currentSettings: ExperimentalSettings
|
|
if let entry = entry?.get(ExperimentalSettings.self) {
|
|
currentSettings = entry
|
|
} else {
|
|
currentSettings = ExperimentalSettings.defaultSettings
|
|
}
|
|
return SharedPreferencesEntry(f(currentSettings))
|
|
})
|
|
}
|
|
}
|