mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
fix: node search by keeping denormalized name columns up to date and backfilling existing nodes (#3839)
This commit is contained in:
parent
ef9c0dc844
commit
1c0dc486e2
5 changed files with 44 additions and 1 deletions
|
|
@ -37,4 +37,6 @@ interface NodeInfoWriteDataSource {
|
|||
suspend fun upsert(metadata: MetadataEntity)
|
||||
|
||||
suspend fun setNodeNotes(num: Int, notes: String)
|
||||
|
||||
suspend fun backfillDenormalizedNames()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,4 +57,7 @@ constructor(
|
|||
|
||||
override suspend fun setNodeNotes(num: Int, notes: String) =
|
||||
withContext(dispatchers.io) { dbManager.withDb { it.nodeInfoDao().setNodeNotes(num, notes) } }
|
||||
|
||||
override suspend fun backfillDenormalizedNames() =
|
||||
withContext(dispatchers.io) { dbManager.withDb { it.nodeInfoDao().backfillDenormalizedNames() } }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,6 +54,13 @@ constructor(
|
|||
private val nodeInfoWriteDataSource: NodeInfoWriteDataSource,
|
||||
private val dispatchers: CoroutineDispatchers,
|
||||
) {
|
||||
init {
|
||||
// Backfill denormalized name columns for existing nodes on startup
|
||||
processLifecycle.coroutineScope.launchWhenCreated {
|
||||
withContext(dispatchers.io) { nodeInfoWriteDataSource.backfillDenormalizedNames() }
|
||||
}
|
||||
}
|
||||
|
||||
// hardware info about our local device (can be null)
|
||||
val myNodeInfo: StateFlow<MyNodeEntity?> =
|
||||
nodeInfoReadDataSource
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue