From 5bac31109d7b18552139b6dc0e6060fb8a410458 Mon Sep 17 00:00:00 2001 From: rene Date: Sat, 30 May 2026 09:40:25 +0200 Subject: [PATCH] Fix /me-Decoding: is_founder/is_partner kommen als SQLite-Int 0/1, nicht Bool MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Das Backend bool-konvertiert nur is_premium explizit; alle anderen 0/1-Spalten gehen unverändert durch FastAPI. Decode-Fehler vorher still verschluckt → jetzt auch geloggt, damit das nicht nochmal passiert. --- BanYaroGo/API/DTOs.swift | 9 +++++++-- BanYaroGo/Auth/AuthSession.swift | 2 ++ BanYaroGo/Views/SettingsView.swift | 4 ++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/BanYaroGo/API/DTOs.swift b/BanYaroGo/API/DTOs.swift index 8240152..caf817d 100644 --- a/BanYaroGo/API/DTOs.swift +++ b/BanYaroGo/API/DTOs.swift @@ -20,13 +20,18 @@ struct UserProfile: Decodable { let realName: String? let rolle: String? let isPremium: Bool? - let isFounder: Bool? - let isPartner: Bool? + // Backend bool-konvertiert nur is_premium; is_founder/is_partner kommen + // als SQLite-Int 0/1 zurück — deshalb hier Int? statt Bool?. + let isFounder: Int? + let isPartner: Int? let founderNumber: Int? let subscriptionTier: String? let avatarUrl: String? let wohnort: String? let bio: String? + + var isFounderFlag: Bool { isFounder == 1 } + var isPartnerFlag: Bool { isPartner == 1 } } // MARK: - Dogs diff --git a/BanYaroGo/Auth/AuthSession.swift b/BanYaroGo/Auth/AuthSession.swift index 73b1652..8e908bc 100644 --- a/BanYaroGo/Auth/AuthSession.swift +++ b/BanYaroGo/Auth/AuthSession.swift @@ -62,6 +62,8 @@ final class AuthSession { } } catch { // Profil-Refresh ist non-critical; Settings zeigt sonst nur die Basics. + // Loggen ist trotzdem nützlich, damit Decode-Fehler nicht stillschweigend untergehen. + print("loadProfile failed: \(error)") } } } diff --git a/BanYaroGo/Views/SettingsView.swift b/BanYaroGo/Views/SettingsView.swift index 6e4b520..6ba3eec 100644 --- a/BanYaroGo/Views/SettingsView.swift +++ b/BanYaroGo/Views/SettingsView.swift @@ -26,10 +26,10 @@ struct SettingsView: View { Section("Account") { LabeledContent("Rolle", value: rolleLabel) - if auth.profile?.isFounder == true { + if auth.profile?.isFounderFlag == true { LabeledContent("Founder", value: founderLabel) } - if auth.profile?.isPartner == true { + if auth.profile?.isPartnerFlag == true { LabeledContent("Partner", value: "Ja") } if let tier = auth.profile?.subscriptionTier, !tier.isEmpty {