diff --git a/submodules/TelegramCore/Sources/ApiUtils/StoreMessage_Telegram.swift b/submodules/TelegramCore/Sources/ApiUtils/StoreMessage_Telegram.swift index 54465d7063..22b1f62a5f 100644 --- a/submodules/TelegramCore/Sources/ApiUtils/StoreMessage_Telegram.swift +++ b/submodules/TelegramCore/Sources/ApiUtils/StoreMessage_Telegram.swift @@ -375,7 +375,7 @@ func messageTextEntitiesFromApiEntities(_ entities: [Api.MessageEntity]) -> [Mes case let .messageEntitySpoiler(offset, length): result.append(MessageTextEntity(range: Int(offset) ..< Int(offset + length), type: .Spoiler)) case let .messageEntityAnimatedEmoji(offset, length): - result.append(MessageTextEntity(range: Int(offset) ..< Int(offset + length), type: .AnimatedEmoji)) + result.append(MessageTextEntity(range: Int(offset) ..< Int(offset + length), type: .AnimatedEmoji(nil))) } } return result diff --git a/submodules/TelegramCore/Sources/SyncCore/SyncCore_TextEntitiesMessageAttribute.swift b/submodules/TelegramCore/Sources/SyncCore/SyncCore_TextEntitiesMessageAttribute.swift index 4807303a57..6906d5ba9f 100644 --- a/submodules/TelegramCore/Sources/SyncCore/SyncCore_TextEntitiesMessageAttribute.swift +++ b/submodules/TelegramCore/Sources/SyncCore/SyncCore_TextEntitiesMessageAttribute.swift @@ -21,7 +21,7 @@ public enum MessageTextEntityType: Equatable { case Underline case BankCard case Spoiler - case AnimatedEmoji + case AnimatedEmoji(MediaId?) case Custom(type: CustomEntityType) } @@ -73,7 +73,7 @@ public struct MessageTextEntity: PostboxCoding, Codable, Equatable { case 17: self.type = .Spoiler case 18: - self.type = .AnimatedEmoji + self.type = .AnimatedEmoji(decoder.decodeObjectForKey("mediaId") as? MediaId) case Int32.max: self.type = .Custom(type: decoder.decodeInt32ForKey("type", orElse: 0)) default: @@ -130,7 +130,7 @@ public struct MessageTextEntity: PostboxCoding, Codable, Equatable { case 17: self.type = .Spoiler case 18: - self.type = .AnimatedEmoji + self.type = .AnimatedEmoji(try? container.decode(MediaId.self, forKey: "mediaId")) case Int32.max: let customType: Int32 = (try? container.decode(Int32.self, forKey: "type")) ?? 0 self.type = .Custom(type: customType) @@ -181,8 +181,13 @@ public struct MessageTextEntity: PostboxCoding, Codable, Equatable { encoder.encodeInt32(16, forKey: "_rawValue") case .Spoiler: encoder.encodeInt32(17, forKey: "_rawValue") - case .AnimatedEmoji: + case let .AnimatedEmoji(mediaId): encoder.encodeInt32(18, forKey: "_rawValue") + if let mediaId = mediaId { + encoder.encodeObject(mediaId, forKey: "mediaId") + } else { + encoder.encodeNil(forKey: "mediaId") + } case let .Custom(type): encoder.encodeInt32(Int32.max, forKey: "_rawValue") encoder.encodeInt32(type, forKey: "type") @@ -233,8 +238,11 @@ public struct MessageTextEntity: PostboxCoding, Codable, Equatable { try container.encode(16 as Int32, forKey: "_rawValue") case .Spoiler: try container.encode(17 as Int32, forKey: "_rawValue") - case .AnimatedEmoji: + case let .AnimatedEmoji(mediaId): try container.encode(18 as Int32, forKey: "_rawValue") + if let mediaId = mediaId { + try container.encode(mediaId, forKey: "mediaId") + } case let .Custom(type): try container.encode(Int32.max as Int32, forKey: "_rawValue") try container.encode(type as Int32, forKey: "type")