mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
chore: add Lifecycle utilities for Compose
and replace collectAsState() with collectAsStateWithLifecycle()
This commit is contained in:
parent
8e7597704b
commit
e03ab70e66
4 changed files with 8 additions and 7 deletions
|
|
@ -28,7 +28,6 @@ import androidx.compose.material.icons.Icons
|
|||
import androidx.compose.material.icons.twotone.Check
|
||||
import androidx.compose.material.icons.twotone.Close
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.collectAsState
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.livedata.observeAsState
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
|
|
@ -52,6 +51,7 @@ import androidx.compose.ui.text.input.ImeAction
|
|||
import androidx.compose.ui.text.input.KeyboardType
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||
import com.geeksville.mesh.analytics.DataPair
|
||||
import com.geeksville.mesh.android.GeeksvilleApplication
|
||||
|
|
@ -115,7 +115,7 @@ fun ChannelScreen(viewModel: UIViewModel = viewModel()) {
|
|||
val connectionState by viewModel.connectionState.observeAsState()
|
||||
val connected = connectionState == MeshService.ConnectionState.CONNECTED
|
||||
|
||||
val channels by viewModel.channels.collectAsState()
|
||||
val channels by viewModel.channels.collectAsStateWithLifecycle()
|
||||
var channelSet by remember(channels.protobuf) { mutableStateOf(channels.protobuf) }
|
||||
|
||||
val primaryChannel = ChannelSet(channelSet).primaryChannel
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue