From 9257da046a3ee00ade514ee0aee98c4126e14056 Mon Sep 17 00:00:00 2001 From: Stefan Lange-Hegermann Date: Mon, 29 Jun 2026 15:26:52 +0200 Subject: [PATCH] Fix library batteries showing 0.0V PocketBase stores battery nominal voltage in voltage_out while voltage_in is 0.0 (not null). The nil-coalescing operator only skips null, so 0.0 was returned instead of the real voltage. Skip zero values when resolving displayVoltage on both platforms. Co-Authored-By: Claude Sonnet 4.6 --- Cable/Loads/ComponentLibraryView.swift | 2 +- .../java/app/voltplan/cable/library/ComponentLibraryItem.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cable/Loads/ComponentLibraryView.swift b/Cable/Loads/ComponentLibraryView.swift index cbd7ce7..ad50eab 100644 --- a/Cable/Loads/ComponentLibraryView.swift +++ b/Cable/Loads/ComponentLibraryView.swift @@ -24,7 +24,7 @@ struct ComponentLibraryItem: Identifiable, Equatable { let iconURL: URL? var displayVoltage: Double? { - voltageIn ?? voltageOut + [voltageIn, voltageOut].compactMap({ $0 }).first(where: { $0 > 0 }) } var current: Double? { diff --git a/android/app/src/main/java/app/voltplan/cable/library/ComponentLibraryItem.kt b/android/app/src/main/java/app/voltplan/cable/library/ComponentLibraryItem.kt index c0c5617..7741245 100644 --- a/android/app/src/main/java/app/voltplan/cable/library/ComponentLibraryItem.kt +++ b/android/app/src/main/java/app/voltplan/cable/library/ComponentLibraryItem.kt @@ -24,7 +24,7 @@ data class ComponentLibraryItem( val iconURL: String?, val affiliateLinks: List, ) { - val displayVoltage: Double? get() = voltageIn ?: voltageOut + val displayVoltage: Double? get() = voltageIn?.takeIf { it > 0 } ?: voltageOut?.takeIf { it > 0 } val current: Double? get() {