fix decoding

This commit is contained in:
Mikhail Filimonov
2024-08-01 08:28:59 -03:00
parent 05372b578c
commit f228641b0a

View File

@@ -17,6 +17,7 @@ public final class AvailableReactions: Equatable, Codable {
case effectAnimation case effectAnimation
case aroundAnimation case aroundAnimation
case centerAnimation case centerAnimation
case isStars
} }
public let isEnabled: Bool public let isEnabled: Bool
@@ -100,7 +101,12 @@ public final class AvailableReactions: Equatable, Codable {
self.isEnabled = try container.decode(Bool.self, forKey: .isEnabled) self.isEnabled = try container.decode(Bool.self, forKey: .isEnabled)
self.isPremium = try container.decodeIfPresent(Bool.self, forKey: .isPremium) ?? false self.isPremium = try container.decodeIfPresent(Bool.self, forKey: .isPremium) ?? false
let isStars = try container.decodeIfPresent(Bool.self, forKey: .isStars) ?? false
if isStars {
self.value = .stars
} else {
self.value = .builtin(try container.decode(String.self, forKey: .value)) self.value = .builtin(try container.decode(String.self, forKey: .value))
}
self.title = try container.decode(String.self, forKey: .title) self.title = try container.decode(String.self, forKey: .title)
let staticIconData = try container.decode(AdaptedPostboxDecoder.RawObjectData.self, forKey: .staticIcon) let staticIconData = try container.decode(AdaptedPostboxDecoder.RawObjectData.self, forKey: .staticIcon)
@@ -143,7 +149,7 @@ public final class AvailableReactions: Equatable, Codable {
case .custom: case .custom:
break break
case .stars: case .stars:
break try container.encode(true, forKey: .isStars)
} }
try container.encode(self.title, forKey: .title) try container.encode(self.title, forKey: .title)