mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 14:20:20 +00:00
Temp
This commit is contained in:
@@ -174,18 +174,6 @@ public struct ChatTextInputState: Codable, Equatable {
|
||||
try container.encode(Int32(self.selectionRange.lowerBound), forKey: "as0")
|
||||
try container.encode(Int32(self.selectionRange.upperBound), forKey: "as1")
|
||||
}
|
||||
|
||||
/*public init(decoder: PostboxDecoder) {
|
||||
self.inputText = ((decoder.decodeObjectForKey("at", decoder: { ChatTextInputStateText(decoder: $0) }) as? ChatTextInputStateText) ?? ChatTextInputStateText()).attributedText()
|
||||
self.selectionRange = Int(decoder.decodeInt32ForKey("as0", orElse: 0)) ..< Int(decoder.decodeInt32ForKey("as1", orElse: 0))
|
||||
}*/
|
||||
|
||||
/*public func encode(_ encoder: PostboxEncoder) {
|
||||
encoder.encodeObject(ChatTextInputStateText(attributedText: self.inputText), forKey: "at")
|
||||
|
||||
encoder.encodeInt32(Int32(self.selectionRange.lowerBound), forKey: "as0")
|
||||
encoder.encodeInt32(Int32(self.selectionRange.upperBound), forKey: "as1")
|
||||
}*/
|
||||
}
|
||||
|
||||
public enum ChatTextInputStateTextAttributeType: Codable, Equatable {
|
||||
@@ -198,7 +186,7 @@ public enum ChatTextInputStateTextAttributeType: Codable, Equatable {
|
||||
public init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: StringCodingKey.self)
|
||||
|
||||
switch (try? container.decodeIfPresent(Int32.self, forKey: "t")) ?? 0 {
|
||||
switch (try? container.decode(Int32.self, forKey: "t")) ?? 0 {
|
||||
case 0:
|
||||
self = .bold
|
||||
case 1:
|
||||
@@ -234,41 +222,6 @@ public enum ChatTextInputStateTextAttributeType: Codable, Equatable {
|
||||
try container.encode(url, forKey: "url")
|
||||
}
|
||||
}
|
||||
|
||||
/*public init(decoder: PostboxDecoder) {
|
||||
switch decoder.decodeInt32ForKey("t", orElse: 0) {
|
||||
case 0:
|
||||
self = .bold
|
||||
case 1:
|
||||
self = .italic
|
||||
case 2:
|
||||
self = .monospace
|
||||
case 3:
|
||||
self = .textMention(EnginePeer.Id(decoder.decodeInt64ForKey("peerId", orElse: 0)))
|
||||
case 4:
|
||||
self = .textUrl(decoder.decodeStringForKey("url", orElse: ""))
|
||||
default:
|
||||
assertionFailure()
|
||||
self = .bold
|
||||
}
|
||||
}
|
||||
|
||||
public func encode(_ encoder: PostboxEncoder) {
|
||||
switch self {
|
||||
case .bold:
|
||||
encoder.encodeInt32(0, forKey: "t")
|
||||
case .italic:
|
||||
encoder.encodeInt32(1, forKey: "t")
|
||||
case .monospace:
|
||||
encoder.encodeInt32(2, forKey: "t")
|
||||
case let .textMention(id):
|
||||
encoder.encodeInt32(3, forKey: "t")
|
||||
encoder.encodeInt64(id.toInt64(), forKey: "peerId")
|
||||
case let .textUrl(url):
|
||||
encoder.encodeInt32(4, forKey: "t")
|
||||
encoder.encodeString(url, forKey: "url")
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
public struct ChatTextInputStateTextAttribute: Codable, Equatable {
|
||||
@@ -283,8 +236,8 @@ public struct ChatTextInputStateTextAttribute: Codable, Equatable {
|
||||
public init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: StringCodingKey.self)
|
||||
self.type = try container.decode(ChatTextInputStateTextAttributeType.self, forKey: "type")
|
||||
let rangeFrom = (try? container.decodeIfPresent(Int32.self, forKey: "range0")) ?? 0
|
||||
let rangeTo = (try? container.decodeIfPresent(Int32.self, forKey: "range1")) ?? 0
|
||||
let rangeFrom = (try? container.decode(Int32.self, forKey: "range0")) ?? 0
|
||||
let rangeTo = (try? container.decode(Int32.self, forKey: "range1")) ?? 0
|
||||
|
||||
self.range = Int(rangeFrom) ..< Int(rangeTo)
|
||||
}
|
||||
@@ -298,17 +251,6 @@ public struct ChatTextInputStateTextAttribute: Codable, Equatable {
|
||||
try container.encode(Int32(self.range.upperBound), forKey: "range1")
|
||||
}
|
||||
|
||||
/*public init(decoder: PostboxDecoder) {
|
||||
self.type = decoder.decodeObjectForKey("type", decoder: { ChatTextInputStateTextAttributeType(decoder: $0) }) as! ChatTextInputStateTextAttributeType
|
||||
self.range = Int(decoder.decodeInt32ForKey("range0", orElse: 0)) ..< Int(decoder.decodeInt32ForKey("range1", orElse: 0))
|
||||
}
|
||||
|
||||
public func encode(_ encoder: PostboxEncoder) {
|
||||
encoder.encodeObject(self.type, forKey: "type")
|
||||
encoder.encodeInt32(Int32(self.range.lowerBound), forKey: "range0")
|
||||
encoder.encodeInt32(Int32(self.range.upperBound), forKey: "range1")
|
||||
}*/
|
||||
|
||||
public static func ==(lhs: ChatTextInputStateTextAttribute, rhs: ChatTextInputStateTextAttribute) -> Bool {
|
||||
return lhs.type == rhs.type && lhs.range == rhs.range
|
||||
}
|
||||
@@ -361,16 +303,6 @@ public struct ChatTextInputStateText: Codable, Equatable {
|
||||
try container.encode(self.attributes, forKey: "attributes")
|
||||
}
|
||||
|
||||
/*public init(decoder: PostboxDecoder) {
|
||||
self.text = decoder.decodeStringForKey("text", orElse: "")
|
||||
self.attributes = decoder.decodeObjectArrayWithDecoderForKey("attributes")
|
||||
}
|
||||
|
||||
public func encode(_ encoder: PostboxEncoder) {
|
||||
encoder.encodeString(self.text, forKey: "text")
|
||||
encoder.encodeObjectArray(self.attributes, forKey: "attributes")
|
||||
}*/
|
||||
|
||||
static public func ==(lhs: ChatTextInputStateText, rhs: ChatTextInputStateText) -> Bool {
|
||||
return lhs.text == rhs.text && lhs.attributes == rhs.attributes
|
||||
}
|
||||
@@ -419,7 +351,7 @@ public final class ChatEmbeddedInterfaceState: PeerChatListEmbeddedInterfaceStat
|
||||
public init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: StringCodingKey.self)
|
||||
self.timestamp = (try? container.decode(Int32.self, forKey: "d")) ?? 0
|
||||
self.text = ((try? container.decodeIfPresent(ChatTextInputStateText.self, forKey: "at")) ?? ChatTextInputStateText()).attributedText()
|
||||
self.text = ((try? container.decode(ChatTextInputStateText.self, forKey: "at")) ?? ChatTextInputStateText()).attributedText()
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
@@ -429,16 +361,6 @@ public final class ChatEmbeddedInterfaceState: PeerChatListEmbeddedInterfaceStat
|
||||
try container.encode(ChatTextInputStateText(attributedText: self.text), forKey: "at")
|
||||
}
|
||||
|
||||
/*public init(decoder: PostboxDecoder) {
|
||||
self.timestamp = decoder.decodeInt32ForKey("d", orElse: 0)
|
||||
self.text = ((decoder.decodeObjectForKey("at", decoder: { ChatTextInputStateText(decoder: $0) }) as? ChatTextInputStateText) ?? ChatTextInputStateText()).attributedText()
|
||||
}
|
||||
|
||||
public func encode(_ encoder: PostboxEncoder) {
|
||||
encoder.encodeInt32(self.timestamp, forKey: "d")
|
||||
encoder.encodeObject(ChatTextInputStateText(attributedText: self.text), forKey: "at")
|
||||
}*/
|
||||
|
||||
public func isEqual(to: PeerChatListEmbeddedInterfaceState) -> Bool {
|
||||
if let to = to as? ChatEmbeddedInterfaceState {
|
||||
return self.timestamp == to.timestamp && self.text.isEqual(to: to.text)
|
||||
|
||||
Reference in New Issue
Block a user