Files
GLEGram-iOS/submodules/TelegramCore/Sources/Settings/NetworkSettings.swift
T
Leeksov 4647310322 GLEGram 12.5 — Initial public release
Based on Swiftgram 12.5 (Telegram iOS 12.5).
All GLEGram features ported and organized in GLEGram/ folder.

Features: Ghost Mode, Saved Deleted Messages, Content Protection Bypass,
Font Replacement, Fake Profile, Chat Export, Plugin System, and more.

See CHANGELOG_12.5.md for full details.
2026-04-06 09:48:12 +03:00

41 lines
1.6 KiB
Swift

import Foundation
import Postbox
import SwiftSignalKit
import MtProtoKit
public func updateNetworkSettingsInteractively(postbox: Postbox, network: Network, _ f: @escaping (NetworkSettings) -> NetworkSettings) -> Signal<Void, NoError> {
return postbox.transaction { transaction -> Void in
updateNetworkSettingsInteractively(transaction: transaction, network: network, f)
}
}
extension NetworkSettings {
var mtNetworkSettings: MTNetworkSettings {
return MTNetworkSettings(reducedBackupDiscoveryTimeout: self.reducedBackupDiscoveryTimeout)
}
}
public func updateNetworkSettingsInteractively(transaction: Transaction, network: Network?, _ f: @escaping (NetworkSettings) -> NetworkSettings) {
var updateNetwork = false
var updatedSettings: NetworkSettings?
transaction.updatePreferencesEntry(key: PreferencesKeys.networkSettings, { current in
let previous = current?.get(NetworkSettings.self) ?? NetworkSettings.defaultSettings
let updated = f(previous)
updatedSettings = updated
if updated.reducedBackupDiscoveryTimeout != previous.reducedBackupDiscoveryTimeout {
updateNetwork = true
}
if updated.backupHostOverride != previous.backupHostOverride {
updateNetwork = true
}
return PreferencesEntry(updated)
})
if let network = network, updateNetwork, let updatedSettings = updatedSettings {
network.context.updateApiEnvironment { current in
return current?.withUpdatedNetworkSettings(updatedSettings.mtNetworkSettings)
}
}
}