From 20dab7c77aedecd52085cfdd1ab86fec4fe9645b Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Tue, 26 Apr 2022 17:44:07 -0400 Subject: [PATCH] Handle missing account emojis on pixelfed instances --- Pachyderm/Sources/Pachyderm/Model/Account.swift | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Pachyderm/Sources/Pachyderm/Model/Account.swift b/Pachyderm/Sources/Pachyderm/Model/Account.swift index bd76d9fc..07da3350 100644 --- a/Pachyderm/Sources/Pachyderm/Model/Account.swift +++ b/Pachyderm/Sources/Pachyderm/Model/Account.swift @@ -49,7 +49,12 @@ public final class Account: AccountProtocol, Decodable { self.avatarStatic = try? container.decode(URL.self, forKey: .avatarStatic) self.header = try? container.decode(URL.self, forKey: .header) 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.bot = try? container.decode(Bool.self, forKey: .bot)