mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
21 lines
760 B
Swift
21 lines
760 B
Swift
import Foundation
|
|
import Postbox
|
|
import SwiftSignalKit
|
|
import MtProtoKit
|
|
|
|
|
|
public func updateContentPrivacySettings(postbox: Postbox, _ f: @escaping (ContentPrivacySettings) -> ContentPrivacySettings) -> Signal<Void, NoError> {
|
|
return postbox.transaction { transaction -> Void in
|
|
var updated: ContentPrivacySettings?
|
|
transaction.updatePreferencesEntry(key: PreferencesKeys.contentPrivacySettings, { current in
|
|
if let current = current?.get(ContentPrivacySettings.self) {
|
|
updated = f(current)
|
|
return PreferencesEntry(updated)
|
|
} else {
|
|
updated = f(ContentPrivacySettings.defaultSettings)
|
|
return PreferencesEntry(updated)
|
|
}
|
|
})
|
|
}
|
|
}
|