mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
use modelMapOf and modelListOf - much nicer!
This commit is contained in:
parent
8311eb1a4d
commit
59d28b75c1
5 changed files with 17 additions and 21 deletions
|
|
@ -1,7 +1,7 @@
|
|||
package com.geeksville.mesh.model
|
||||
|
||||
import android.os.RemoteException
|
||||
import androidx.compose.mutableStateOf
|
||||
import androidx.compose.frames.modelListOf
|
||||
import com.geeksville.android.Logging
|
||||
import com.geeksville.mesh.MeshProtos
|
||||
import com.geeksville.mesh.utf8
|
||||
|
|
@ -21,7 +21,7 @@ data class TextMessage(
|
|||
|
||||
|
||||
object MessagesState : Logging {
|
||||
val testTexts = listOf(
|
||||
private val testTexts = arrayOf(
|
||||
TextMessage(
|
||||
"+16508765310",
|
||||
"I found the cache"
|
||||
|
|
@ -34,15 +34,11 @@ object MessagesState : Logging {
|
|||
|
||||
// If the following (unused otherwise) line is commented out, the IDE preview window works.
|
||||
// if left in the preview always renders as empty.
|
||||
val messages = mutableStateOf(testTexts, { a, b ->
|
||||
a.size == b.size // If the # of messages changes, consider it important for rerender
|
||||
})
|
||||
val messages = modelListOf(*testTexts)
|
||||
|
||||
/// add a message our GUI list of past msgs
|
||||
fun addMessage(m: TextMessage) {
|
||||
val l = messages.value.toMutableList()
|
||||
l.add(m)
|
||||
messages.value = l
|
||||
messages.add(m)
|
||||
}
|
||||
|
||||
/// Send a message and added it to our GUI log
|
||||
|
|
|
|||
|
|
@ -44,8 +44,8 @@ object NodeDB {
|
|||
val myId = mutableStateOf("+16508765309")
|
||||
|
||||
/// A map from nodeid to to nodeinfo
|
||||
val nodes = mutableStateOf(testNodes.map { it.user!!.id to it }.toMap())
|
||||
val nodes = mutableMapOf(* testNodes.map { it.user!!.id to it }.toTypedArray())
|
||||
|
||||
/// Could be null if we haven't received our node DB yet
|
||||
val ourNodeInfo get() = nodes.value[myId.value!!]
|
||||
val ourNodeInfo get() = nodes[myId.value!!]
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue