mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-24 07:05:35 +00:00
Merge branch 'master' into postbox-refactoring-1
This commit is contained in:
@@ -8,11 +8,11 @@ import MtProtoKit
|
||||
public func updateGlobalNotificationSettingsInteractively(postbox: Postbox, _ f: @escaping (GlobalNotificationSettingsSet) -> GlobalNotificationSettingsSet) -> Signal<Void, NoError> {
|
||||
return postbox.transaction { transaction -> Void in
|
||||
transaction.updatePreferencesEntry(key: PreferencesKeys.globalNotifications, { current in
|
||||
if let current = current as? GlobalNotificationSettings {
|
||||
return GlobalNotificationSettings(toBeSynchronized: f(current.effective), remote: current.remote)
|
||||
if let current = current?.get(GlobalNotificationSettings.self) {
|
||||
return PreferencesEntry(GlobalNotificationSettings(toBeSynchronized: f(current.effective), remote: current.remote))
|
||||
} else {
|
||||
let settings = f(GlobalNotificationSettingsSet.defaultSettings)
|
||||
return GlobalNotificationSettings(toBeSynchronized: settings, remote: settings)
|
||||
return PreferencesEntry(GlobalNotificationSettings(toBeSynchronized: settings, remote: settings))
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -56,7 +56,7 @@ private enum SynchronizeGlobalSettingsData: Equatable {
|
||||
func managedGlobalNotificationSettings(postbox: Postbox, network: Network) -> Signal<Void, NoError> {
|
||||
let data = postbox.preferencesView(keys: [PreferencesKeys.globalNotifications])
|
||||
|> map { view -> SynchronizeGlobalSettingsData in
|
||||
if let preferences = view.values[PreferencesKeys.globalNotifications] as? GlobalNotificationSettings {
|
||||
if let preferences = view.values[PreferencesKeys.globalNotifications]?.get(GlobalNotificationSettings.self) {
|
||||
if let settings = preferences.toBeSynchronized {
|
||||
return .push(settings)
|
||||
} else {
|
||||
@@ -77,10 +77,10 @@ func managedGlobalNotificationSettings(postbox: Postbox, network: Network) -> Si
|
||||
|> mapToSignal { settings -> Signal<Void, NoError> in
|
||||
return postbox.transaction { transaction -> Void in
|
||||
transaction.updatePreferencesEntry(key: PreferencesKeys.globalNotifications, { current in
|
||||
if let current = current as? GlobalNotificationSettings {
|
||||
return GlobalNotificationSettings(toBeSynchronized: current.toBeSynchronized, remote: settings)
|
||||
if let current = current?.get(GlobalNotificationSettings.self) {
|
||||
return PreferencesEntry(GlobalNotificationSettings(toBeSynchronized: current.toBeSynchronized, remote: settings))
|
||||
} else {
|
||||
return GlobalNotificationSettings(toBeSynchronized: nil, remote: settings)
|
||||
return PreferencesEntry(GlobalNotificationSettings(toBeSynchronized: nil, remote: settings))
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -89,8 +89,8 @@ func managedGlobalNotificationSettings(postbox: Postbox, network: Network) -> Si
|
||||
return pushedNotificationSettings(network: network, settings: settings)
|
||||
|> then(postbox.transaction { transaction -> Void in
|
||||
transaction.updatePreferencesEntry(key: PreferencesKeys.globalNotifications, { current in
|
||||
if let current = current as? GlobalNotificationSettings, current.toBeSynchronized == settings {
|
||||
return GlobalNotificationSettings(toBeSynchronized: nil, remote: settings)
|
||||
if let current = current?.get(GlobalNotificationSettings.self), current.toBeSynchronized == settings {
|
||||
return PreferencesEntry(GlobalNotificationSettings(toBeSynchronized: nil, remote: settings))
|
||||
} else {
|
||||
return current
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user