Fix preview when forwarding from Saved Messages

This commit is contained in:
Ilya Laktyushin
2021-11-11 21:35:11 +04:00
parent 49f272be5b
commit 383b555437
3 changed files with 13 additions and 15 deletions

View File

@@ -59,7 +59,7 @@ public final class TelegramThemeSettings: Codable, Equatable {
self.baseTheme = TelegramBaseTheme(rawValue: try container.decode(Int32.self, forKey: "baseTheme")) ?? .classic
self.accentColor = UInt32(bitPattern: try container.decode(Int32.self, forKey: "accent"))
self.outgoingAccentColor = (try container.decodeIfPresent(Int32.self, forKey: "outgoingAccent")).flatMap { UInt32(bitPattern: $0) }
let messageColors = try container.decode([Int32].self, forKey: "messageColors")
let messageColors = try container.decodeIfPresent([Int32].self, forKey: "messageColors") ?? []
if !messageColors.isEmpty {
self.messageColors = messageColors.map(UInt32.init(bitPattern:))
} else {
@@ -69,7 +69,7 @@ public final class TelegramThemeSettings: Codable, Equatable {
self.messageColors = []
}
}
self.animateMessageColors = try container.decode(Int32.self, forKey: "animateMessageColors") != 0
self.animateMessageColors = (try container.decodeIfPresent(Int32.self, forKey: "animateMessageColors") ?? 0) != 0
self.wallpaper = (try container.decodeIfPresent(TelegramWallpaperNativeCodable.self, forKey: "wallpaper"))?.value
}