Fix crash when extra_usage fields are null

This commit is contained in:
superdooper86
2026-05-07 13:36:23 +02:00
parent edd8d42c8d
commit 464884e88f
2 changed files with 14 additions and 6 deletions
+2 -2
View File
@@ -491,7 +491,7 @@ struct FooterBar: View {
struct ExtraUsageRow: View {
let extra: ExtraUsage
var pct: Double { min(100, max(0, extra.utilization)) }
var pct: Double { min(100, max(0, extra.utilization ?? 0)) }
var color: Color { pct > 80 ? .red : pct > 50 ? .orange : .green }
var body: some View {
@@ -504,7 +504,7 @@ struct ExtraUsageRow: View {
.font(.system(size: 12, weight: .semibold))
.foregroundColor(.secondary)
Spacer()
Text("\(extra.currency) \(String(format: "%.2f", extra.usedCredits / 100)) / \(String(format: "%.2f", extra.monthlyLimit / 100))")
Text("\(extra.currency ?? "") \(String(format: "%.2f", (extra.usedCredits ?? 0) / 100)) / \(String(format: "%.2f", (extra.monthlyLimit ?? 0) / 100))")
.font(.system(size: 11.5, weight: .medium).monospacedDigit())
.foregroundColor(color)
}