From a848f6e425e1a4224abcbf4b0505e2078e5ba51d Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sun, 2 Jun 2024 09:44:20 -0700 Subject: [PATCH] Fix error on Pixelfed/Firefish due to missing followers/following counts Closes #483 --- Packages/Pachyderm/Sources/Pachyderm/Model/Account.swift | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Packages/Pachyderm/Sources/Pachyderm/Model/Account.swift b/Packages/Pachyderm/Sources/Pachyderm/Model/Account.swift index 646254b85f..baf2d1e798 100644 --- a/Packages/Pachyderm/Sources/Pachyderm/Model/Account.swift +++ b/Packages/Pachyderm/Sources/Pachyderm/Model/Account.swift @@ -40,8 +40,9 @@ public final class Account: AccountProtocol, Decodable, Sendable { self.displayName = try container.decode(String.self, forKey: .displayName) self.locked = try container.decode(Bool.self, forKey: .locked) self.createdAt = try container.decode(Date.self, forKey: .createdAt) - self.followersCount = try container.decode(Int.self, forKey: .followersCount) - self.followingCount = try container.decode(Int.self, forKey: .followingCount) + // some instance types (pixelfed, firefish) seem to sometimes send null for these fields, so just fallback to 0 + self.followersCount = try container.decodeIfPresent(Int.self, forKey: .followersCount) ?? 0 + self.followingCount = try container.decodeIfPresent(Int.self, forKey: .followingCount) ?? 0 self.statusesCount = try container.decode(Int.self, forKey: .statusesCount) self.note = try container.decode(String.self, forKey: .note) self.url = try container.decode(URL.self, forKey: .url)