mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
fix: crash in charts, nav (#2290)
Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit is contained in:
parent
4500ba0c0a
commit
9819a89b97
3 changed files with 25 additions and 9 deletions
|
|
@ -117,8 +117,8 @@ data class EnvironmentMetricsState(
|
|||
shouldPlot[Environment.IAQ.ordinal] = true
|
||||
}
|
||||
|
||||
val min = minValues.minOf { it }
|
||||
val max = maxValues.maxOf { it }
|
||||
val min = if (minValues.isEmpty()) 0f else minValues.minOf { it }
|
||||
val max = if (maxValues.isEmpty()) 0f else maxValues.maxOf { it }
|
||||
|
||||
val (minPressure, maxPressure) = Pair(
|
||||
telemetries.minBy { it.environmentMetrics.barometricPressure },
|
||||
|
|
|
|||
|
|
@ -19,8 +19,11 @@ package com.geeksville.mesh.navigation
|
|||
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.hilt.navigation.compose.hiltViewModel
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import androidx.navigation.NavDestination
|
||||
import androidx.navigation.NavDestination.Companion.hasRoute
|
||||
import androidx.navigation.NavHostController
|
||||
|
|
@ -47,6 +50,9 @@ const val DEEP_LINK_BASE_URI = "meshtastic://meshtastic"
|
|||
sealed interface Graph : Route
|
||||
@Serializable
|
||||
sealed interface Route {
|
||||
@Serializable
|
||||
data object Dispatcher : Route
|
||||
|
||||
@Serializable
|
||||
data object DebugPanel : Route
|
||||
}
|
||||
|
|
@ -80,15 +86,25 @@ fun NavGraph(
|
|||
) {
|
||||
NavHost(
|
||||
navController = navController,
|
||||
startDestination = if (uIViewModel.isConnected()) {
|
||||
NodesRoutes.NodesGraph
|
||||
} else {
|
||||
ConnectionsRoutes.ConnectionsGraph
|
||||
},
|
||||
startDestination = Route.Dispatcher,
|
||||
modifier = modifier,
|
||||
) {
|
||||
composable<Route.Dispatcher> {
|
||||
val isConnected by uIViewModel.isConnected.collectAsStateWithLifecycle(false)
|
||||
LaunchedEffect(isConnected) {
|
||||
if (isConnected) {
|
||||
navController.navigate(NodesRoutes.NodesGraph) {
|
||||
popUpTo(Route.Dispatcher) { inclusive = true }
|
||||
}
|
||||
} else {
|
||||
navController.navigate(ConnectionsRoutes.ConnectionsGraph) {
|
||||
popUpTo(Route.Dispatcher) { inclusive = true }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
contactsGraph(navController, uIViewModel)
|
||||
nodesGraph(navController, uIViewModel,)
|
||||
nodesGraph(navController, uIViewModel)
|
||||
mapGraph(navController, uIViewModel)
|
||||
channelsGraph(navController, uIViewModel)
|
||||
connectionsGraph(navController, uIViewModel, bluetoothViewModel)
|
||||
|
|
|
|||
|
|
@ -473,7 +473,7 @@ private fun TopBarActions(
|
|||
) {
|
||||
val ourNode by viewModel.ourNodeInfo.collectAsStateWithLifecycle()
|
||||
val isConnected by viewModel.isConnected.collectAsStateWithLifecycle(false)
|
||||
AnimatedVisibility(ourNode != null) {
|
||||
AnimatedVisibility(ourNode != null && currentDestination?.isTopLevel() == true) {
|
||||
ourNode?.let {
|
||||
NodeChip(
|
||||
node = it,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue