Swiftgram/submodules/TelegramCore/Sources/CacheStorageSettings.swift
2019-11-01 17:11:12 +04:00

20 lines
712 B
Swift

import Foundation
import Postbox
import SwiftSignalKit
import SyncCore
public func updateCacheStorageSettingsInteractively(accountManager: AccountManager, _ f: @escaping (CacheStorageSettings) -> CacheStorageSettings) -> Signal<Void, NoError> {
return accountManager.transaction { transaction -> Void in
transaction.updateSharedData(SharedDataKeys.cacheStorageSettings, { entry in
let currentSettings: CacheStorageSettings
if let entry = entry as? CacheStorageSettings {
currentSettings = entry
} else {
currentSettings = CacheStorageSettings.defaultSettings
}
return f(currentSettings)
})
}
}