mirror of
https://github.com/ichmagmaus111/ghostgram.git
synced 2026-09-22 20:30:41 +02:00
Update Ghostgram features
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
|
||||
|
||||
swift_library(
|
||||
name = "SGStatus",
|
||||
srcs = glob([
|
||||
"Sources/**/*.swift",
|
||||
]),
|
||||
module_name = "SGStatus",
|
||||
deps = [
|
||||
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
|
||||
"//submodules/TelegramCore:TelegramCore",
|
||||
"//submodules/TelegramUIPreferences:TelegramUIPreferences",
|
||||
],
|
||||
visibility = [
|
||||
"//visibility:public",
|
||||
],
|
||||
)
|
||||
@@ -0,0 +1,42 @@
|
||||
import Foundation
|
||||
import SwiftSignalKit
|
||||
import TelegramCore
|
||||
import TelegramUIPreferences
|
||||
|
||||
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))
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user