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 <noreply@anthropic.com>
This commit is contained in:
@@ -24,7 +24,7 @@ struct ComponentLibraryItem: Identifiable, Equatable {
|
|||||||
let iconURL: URL?
|
let iconURL: URL?
|
||||||
|
|
||||||
var displayVoltage: Double? {
|
var displayVoltage: Double? {
|
||||||
voltageIn ?? voltageOut
|
[voltageIn, voltageOut].compactMap({ $0 }).first(where: { $0 > 0 })
|
||||||
}
|
}
|
||||||
|
|
||||||
var current: Double? {
|
var current: Double? {
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ data class ComponentLibraryItem(
|
|||||||
val iconURL: String?,
|
val iconURL: String?,
|
||||||
val affiliateLinks: List<AffiliateLink>,
|
val affiliateLinks: List<AffiliateLink>,
|
||||||
) {
|
) {
|
||||||
val displayVoltage: Double? get() = voltageIn ?: voltageOut
|
val displayVoltage: Double? get() = voltageIn?.takeIf { it > 0 } ?: voltageOut?.takeIf { it > 0 }
|
||||||
|
|
||||||
val current: Double?
|
val current: Double?
|
||||||
get() {
|
get() {
|
||||||
|
|||||||
Reference in New Issue
Block a user