Handle missing account emojis on pixelfed instances

This commit is contained in:
Shadowfacts 2022-04-26 17:44:07 -04:00
parent 4e105e0fbc
commit 20dab7c77a
1 changed files with 6 additions and 1 deletions

View File

@ -49,7 +49,12 @@ public final class Account: AccountProtocol, Decodable {
self.avatarStatic = try? container.decode(URL.self, forKey: .avatarStatic) self.avatarStatic = try? container.decode(URL.self, forKey: .avatarStatic)
self.header = try? container.decode(URL.self, forKey: .header) self.header = try? container.decode(URL.self, forKey: .header)
self.headerStatic = try? container.decode(URL.self, forKey: .headerStatic) self.headerStatic = try? container.decode(URL.self, forKey: .headerStatic)
self.emojis = try container.decode([Emoji].self, forKey: .emojis) // even up-to-date pixelfed instances sometimes lack this, for reasons unclear
if let emojis = try container.decodeIfPresent([Emoji].self, forKey: .emojis) {
self.emojis = emojis
} else {
self.emojis = []
}
self.fields = (try? container.decode([Field].self, forKey: .fields)) ?? [] self.fields = (try? container.decode([Field].self, forKey: .fields)) ?? []
self.bot = try? container.decode(Bool.self, forKey: .bot) self.bot = try? container.decode(Bool.self, forKey: .bot)