mirror of
https://github.com/GLEGram/GLEGram-iOS.git
synced 2026-04-27 13:27:18 +02:00
4647310322
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.
42 lines
1.3 KiB
Swift
42 lines
1.3 KiB
Swift
import Foundation
|
|
import SwiftSignalKit
|
|
import TelegramCore
|
|
|
|
public struct SGStatus: Equatable, Codable {
|
|
public var status: Int64
|
|
|
|
public static var `default`: SGStatus {
|
|
return SGStatus(status: 1)
|
|
}
|
|
|
|
public init(status: Int64) {
|
|
self.status = status
|
|
}
|
|
|
|
public init(from decoder: Decoder) throws {
|
|
let container = try decoder.container(keyedBy: StringCodingKey.self)
|
|
|
|
self.status = try container.decodeIfPresent(Int64.self, forKey: "status") ?? 1
|
|
}
|
|
|
|
public func encode(to encoder: Encoder) throws {
|
|
var container = encoder.container(keyedBy: StringCodingKey.self)
|
|
|
|
try container.encodeIfPresent(self.status, forKey: "status")
|
|
}
|
|
}
|
|
|
|
public func updateSGStatusInteractively(accountManager: AccountManager<TelegramAccountManagerTypes>, _ f: @escaping (SGStatus) -> SGStatus) -> Signal<Void, NoError> {
|
|
return accountManager.transaction { transaction -> Void in
|
|
transaction.updateSharedData(ApplicationSpecificSharedDataKeys.sgStatus, { entry in
|
|
let currentSettings: SGStatus
|
|
if let entry = entry?.get(SGStatus.self) {
|
|
currentSettings = entry
|
|
} else {
|
|
currentSettings = SGStatus.default
|
|
}
|
|
return SharedPreferencesEntry(f(currentSettings))
|
|
})
|
|
}
|
|
}
|