fix: Show profile name on cached-only device cards

Add label property to PodDevice, populated from the profile in DeviceMonitor. Cards now use device.label instead of reaching through BLE metadata, so cached-only cards display the profile name instead of '?'.
This commit is contained in:
darken
2026-04-02 15:37:33 +02:00
parent 5ae15d828d
commit 94156b6200
4 changed files with 10 additions and 7 deletions
@@ -95,7 +95,7 @@ fun DualPodsCard(
Column(modifier = Modifier.weight(1f)) {
Text(
text = device.meta?.profile?.label ?: "?",
text = device.label ?: "?",
style = MaterialTheme.typography.titleMedium,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
@@ -103,7 +103,7 @@ fun SinglePodsCard(
Column(modifier = Modifier.weight(1f)) {
Text(
text = device.meta?.profile?.label ?: "?",
text = device.label ?: "?",
style = MaterialTheme.typography.titleMedium,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
@@ -33,12 +33,13 @@ class DeviceMonitor @Inject constructor(
// Live devices — BLE + AAP + cached fallback for missing fields
val liveDevices = pods.map { pod ->
val bondedAddress = pod.meta?.profile?.address
val profileId = pod.meta?.profile?.id
val profile = pod.meta?.profile
PodDevice(
profileId = profileId,
profileId = profile?.id,
label = profile?.label,
ble = pod,
aap = bondedAddress?.let { aapStates[it] },
cached = profileId?.let { cachedStates[it] },
cached = profile?.id?.let { cachedStates[it] },
)
}
@@ -48,7 +49,7 @@ class DeviceMonitor @Inject constructor(
.filter { it.id !in liveProfileIds }
.mapNotNull { profile ->
cachedStates[profile.id]?.let {
PodDevice(profileId = profile.id, ble = null, aap = null, cached = it)
PodDevice(profileId = profile.id, label = profile.label, ble = null, aap = null, cached = it)
}
}
@@ -67,7 +68,8 @@ class DeviceMonitor @Inject constructor(
val cached = deviceStateCache.load(profileId)
if (cached != null) {
log(TAG) { "Found cached state for profile $profileId" }
return PodDevice(profileId = profileId, ble = null, aap = null, cached = cached)
val profileLabel = profilesRepo.profiles.firstOrNull()?.firstOrNull { it.id == profileId }?.label
return PodDevice(profileId = profileId, label = profileLabel, ble = null, aap = null, cached = cached)
}
log(TAG) { "No device found for profile $profileId" }
@@ -29,6 +29,7 @@ import java.time.Instant
@Stable
data class PodDevice(
val profileId: String?,
val label: String? = null,
internal val ble: BlePodSnapshot?,
internal val aap: AapPodState?,
internal val cached: CachedDeviceState? = null,