mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
refactor: replace service local node db with Room NodeDB
This commit is contained in:
parent
84939a74d2
commit
39a18e6418
3 changed files with 31 additions and 92 deletions
|
|
@ -22,7 +22,6 @@ import kotlinx.coroutines.flow.Flow
|
|||
import kotlinx.coroutines.flow.SharedFlow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import kotlinx.coroutines.flow.combine
|
||||
import kotlinx.coroutines.flow.firstOrNull
|
||||
import javax.inject.Inject
|
||||
|
||||
/**
|
||||
|
|
@ -50,17 +49,15 @@ class RadioConfigRepository @Inject constructor(
|
|||
/**
|
||||
* Flow representing the [MyNodeInfo] database.
|
||||
*/
|
||||
fun myNodeInfoFlow(): Flow<MyNodeInfo?> = nodeDB.myNodeInfoFlow()
|
||||
suspend fun getMyNodeInfo(): MyNodeInfo? = myNodeInfoFlow().firstOrNull()
|
||||
val myNodeInfo: StateFlow<MyNodeInfo?> get() = nodeDB.myNodeInfo
|
||||
val nodeDBbyNum: StateFlow<Map<Int, NodeInfo>> get() = nodeDB.nodeDBbyNum
|
||||
|
||||
/**
|
||||
* Flow representing the [NodeInfo] database.
|
||||
*/
|
||||
suspend fun getNodes(): List<NodeInfo>? = nodeDB.getNodes().firstOrNull()
|
||||
val nodeDBbyNum: StateFlow<Map<Int, NodeInfo>> get() = nodeDB.nodeDBbyNum
|
||||
|
||||
suspend fun upsert(node: NodeInfo) = nodeDB.upsert(node)
|
||||
suspend fun clearNodeDB() = nodeDB.clearNodeDB()
|
||||
suspend fun installNodeDB(mi: MyNodeInfo, nodes: List<NodeInfo>) {
|
||||
nodeDB.installNodeDB(mi, nodes)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue