[WIP] Animated emoji

This commit is contained in:
Ali
2022-07-08 19:53:20 +02:00
parent 1ac654e8b2
commit ed59ead31e
108 changed files with 1005 additions and 678 deletions

View File

@@ -249,7 +249,7 @@ public enum ChatTextInputStateTextAttributeType: Codable, Equatable {
case monospace
case textMention(EnginePeer.Id)
case textUrl(String)
case customEmoji(stickerPack: StickerPackReference, fileId: Int64)
case customEmoji(stickerPack: StickerPackReference?, fileId: Int64)
public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: StringCodingKey.self)
@@ -268,7 +268,7 @@ public enum ChatTextInputStateTextAttributeType: Codable, Equatable {
let url = (try? container.decode(String.self, forKey: "url")) ?? ""
self = .textUrl(url)
case 5:
let stickerPack = try container.decode(StickerPackReference.self, forKey: "s")
let stickerPack = try container.decodeIfPresent(StickerPackReference.self, forKey: "s")
let fileId = try container.decode(Int64.self, forKey: "f")
self = .customEmoji(stickerPack: stickerPack, fileId: fileId)
default:
@@ -294,7 +294,7 @@ public enum ChatTextInputStateTextAttributeType: Codable, Equatable {
try container.encode(url, forKey: "url")
case let .customEmoji(stickerPack, fileId):
try container.encode(5 as Int32, forKey: "t")
try container.encode(stickerPack, forKey: "s")
try container.encodeIfPresent(stickerPack, forKey: "s")
try container.encode(fileId, forKey: "f")
}
}
@@ -400,7 +400,7 @@ public struct ChatTextInputStateText: Codable, Equatable {
case let .textUrl(url):
result.addAttribute(ChatTextInputAttributes.textUrl, value: ChatTextInputTextUrlAttribute(url: url), range: NSRange(location: attribute.range.lowerBound, length: attribute.range.count))
case let .customEmoji(stickerPack, fileId):
result.addAttribute(ChatTextInputAttributes.customEmoji, value: ChatTextInputTextCustomEmojiAttribute(stickerPack: stickerPack, fileId: fileId), range: NSRange(location: attribute.range.lowerBound, length: attribute.range.count))
result.addAttribute(ChatTextInputAttributes.customEmoji, value: ChatTextInputTextCustomEmojiAttribute(stickerPack: stickerPack, fileId: fileId, file: nil), range: NSRange(location: attribute.range.lowerBound, length: attribute.range.count))
}
}
return result