mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2026-04-07 21:57:51 +00:00
Version 10.13
This commit is contained in:
@@ -1,29 +1,37 @@
|
||||
import Foundation
|
||||
import Postbox
|
||||
import SGWebSettingsScheme
|
||||
|
||||
public struct AppConfiguration: Codable, Equatable {
|
||||
// MARK: Swiftgram
|
||||
public var sgWebSettings: SGWebSettings
|
||||
|
||||
public var data: JSON?
|
||||
public var hash: Int32
|
||||
|
||||
public static var defaultValue: AppConfiguration {
|
||||
return AppConfiguration(data: nil, hash: 0)
|
||||
return AppConfiguration(sgWebSettings: SGWebSettings.defaultValue, data: nil, hash: 0)
|
||||
}
|
||||
|
||||
init(data: JSON?, hash: Int32) {
|
||||
init(sgWebSettings: SGWebSettings, data: JSON?, hash: Int32) {
|
||||
self.sgWebSettings = sgWebSettings
|
||||
self.data = data
|
||||
self.hash = hash
|
||||
}
|
||||
|
||||
public init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: StringCodingKey.self)
|
||||
|
||||
|
||||
self.sgWebSettings = (try container.decodeIfPresent(SGWebSettings.self, forKey: "sg")) ?? SGWebSettings.defaultValue
|
||||
self.data = try container.decodeIfPresent(JSON.self, forKey: "data")
|
||||
self.hash = (try container.decodeIfPresent(Int32.self, forKey: "storedHash")) ?? 0
|
||||
}
|
||||
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: StringCodingKey.self)
|
||||
|
||||
|
||||
try container.encode(self.sgWebSettings, forKey: "sg")
|
||||
try container.encodeIfPresent(self.data, forKey: "data")
|
||||
try container.encode(self.hash, forKey: "storedHash")
|
||||
}
|
||||
|
||||
@@ -87,3 +87,47 @@ public class TranslationMessageAttribute: MessageAttribute, Equatable {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// MARK: Swiftgram
|
||||
public class QuickTranslationMessageAttribute: MessageAttribute, Equatable {
|
||||
public let originalText: String
|
||||
public let originalEntities: [MessageTextEntity]
|
||||
|
||||
public var associatedPeerIds: [PeerId] {
|
||||
return []
|
||||
}
|
||||
|
||||
public init(
|
||||
text: String,
|
||||
entities: [MessageTextEntity]
|
||||
) {
|
||||
self.originalText = text
|
||||
self.originalEntities = entities
|
||||
}
|
||||
|
||||
required public init(decoder: PostboxDecoder) {
|
||||
self.originalText = decoder.decodeStringForKey("originalText", orElse: "")
|
||||
self.originalEntities = decoder.decodeObjectArrayWithDecoderForKey("originalEntities")
|
||||
}
|
||||
|
||||
public func encode(_ encoder: PostboxEncoder) {
|
||||
encoder.encodeString(self.originalText, forKey: "originalText")
|
||||
encoder.encodeObjectArray(self.originalEntities, forKey: "originalEntities")
|
||||
}
|
||||
|
||||
public static func ==(lhs: QuickTranslationMessageAttribute, rhs: QuickTranslationMessageAttribute) -> Bool {
|
||||
if lhs.originalText != rhs.originalText {
|
||||
return false
|
||||
}
|
||||
if lhs.originalEntities != rhs.originalEntities {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user