From 3373305b23620f7b404d51b28c018fa3621b4a1a Mon Sep 17 00:00:00 2001 From: rene Date: Sat, 30 May 2026 12:35:50 +0200 Subject: [PATCH] Tagebuch-Decode-Fix: media_items statt media, is_milestone als Int 0/1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Backend liefert das Foto-Array unter 'media_items' (in _entry_dict), nicht 'media'. Außerdem ist is_milestone wieder eine SQLite-Int-Spalte 0/1 — der bekannte Bool-Quirk. Mit Bool? in der DTO bricht die Decoder ab und die ganze Liste verschwindet stillschweigend in den Fehler-Zustand. --- BanYaroGo/API/DTOs.swift | 7 +++++-- BanYaroGo/Views/TagebuchView.swift | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/BanYaroGo/API/DTOs.swift b/BanYaroGo/API/DTOs.swift index 753b477..8f2c6a8 100644 --- a/BanYaroGo/API/DTOs.swift +++ b/BanYaroGo/API/DTOs.swift @@ -204,9 +204,12 @@ struct DiaryEntry: Decodable, Identifiable { let gpsLat: Double? let gpsLon: Double? let locationName: String? - let isMilestone: Bool? - let media: [DiaryMedia]? + // is_milestone kommt als SQLite-Int 0/1 — Backend bool-konvertiert es nicht. + let isMilestone: Int? + let mediaItems: [DiaryMedia]? let createdAt: String? + + var isMilestoneFlag: Bool { isMilestone == 1 } } struct DiaryMedia: Decodable, Identifiable { diff --git a/BanYaroGo/Views/TagebuchView.swift b/BanYaroGo/Views/TagebuchView.swift index e935c95..5cc517c 100644 --- a/BanYaroGo/Views/TagebuchView.swift +++ b/BanYaroGo/Views/TagebuchView.swift @@ -77,7 +77,7 @@ private struct DiaryRow: View { var body: some View { VStack(alignment: .leading, spacing: 8) { HStack(alignment: .firstTextBaseline) { - if entry.isMilestone == true || entry.typ == "meilenstein" { + if entry.isMilestoneFlag || entry.typ == "meilenstein" { Image(systemName: "star.fill").foregroundStyle(.orange) } if let titel = entry.titel, !titel.isEmpty { @@ -103,7 +103,7 @@ private struct DiaryRow: View { .font(.caption) .foregroundStyle(.tertiary) } - if let media = entry.media, !media.isEmpty { + if let media = entry.mediaItems, !media.isEmpty { ScrollView(.horizontal, showsIndicators: false) { HStack(spacing: 6) { ForEach(media) { m in