Fix device cards being shown even if Bluetooth is disabled.

This commit is contained in:
darken
2022-01-20 15:52:12 +01:00
parent 5d72d0116b
commit 7df24f9c76
@@ -108,37 +108,6 @@ class OverviewFragmentVM @Inject constructor(
val items = mutableListOf<OverviewAdapter.Item>()
val mainPod = podMonitor.mainDevice.first()
val now = Instant.now()
pods
.map {
when (it) {
is DualApplePods -> DualApplePodsCardVH.Item(
now = now,
device = it,
showDebug = isDebugMode,
isMainPod = it == mainPod,
)
is SingleApplePods -> SingleApplePodsCardVH.Item(
now = now,
device = it,
showDebug = isDebugMode,
isMainPod = it == mainPod,
)
is BasicSingleApplePods -> BasicSingleApplePodsCardVH.Item(
now = now,
device = it,
showDebug = isDebugMode,
isMainPod = it == mainPod,
)
else -> UnknownPodDeviceCardVH.Item(
now = now,
device = it,
showDebug = isDebugMode,
isMainPod = it == mainPod,
)
}
}
.run { items.addAll(this) }
permissions
.map { perm ->
@@ -157,6 +126,40 @@ class OverviewFragmentVM @Inject constructor(
}
}
if (permissions.isEmpty() && isBluetoothEnabled) {
pods
.map {
val now = Instant.now()
when (it) {
is DualApplePods -> DualApplePodsCardVH.Item(
now = now,
device = it,
showDebug = isDebugMode,
isMainPod = it == mainPod,
)
is SingleApplePods -> SingleApplePodsCardVH.Item(
now = now,
device = it,
showDebug = isDebugMode,
isMainPod = it == mainPod,
)
is BasicSingleApplePods -> BasicSingleApplePodsCardVH.Item(
now = now,
device = it,
showDebug = isDebugMode,
isMainPod = it == mainPod,
)
else -> UnknownPodDeviceCardVH.Item(
now = now,
device = it,
showDebug = isDebugMode,
isMainPod = it == mainPod,
)
}
}
.run { items.addAll(this) }
}
items
}
.catch { errorEvents.postValue(it) }