mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
refactor: getContacts() DAO using Map return type
This commit is contained in:
parent
84a8162f5f
commit
1c5e2dbefc
4 changed files with 15 additions and 13 deletions
|
|
@ -18,6 +18,8 @@ class PacketRepository @Inject constructor(private val packetDaoLazy: dagger.Laz
|
|||
packetDao.getAllPackets()
|
||||
}
|
||||
|
||||
fun getContacts(): Flow<Map<String, Packet>> = packetDao.getContactKeys()
|
||||
|
||||
suspend fun getQueuedPackets(): List<DataPacket>? = withContext(Dispatchers.IO) {
|
||||
packetDao.getQueuedPackets()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.geeksville.mesh.database.dao
|
|||
|
||||
import androidx.room.Dao
|
||||
import androidx.room.Insert
|
||||
import androidx.room.MapColumn
|
||||
import androidx.room.Update
|
||||
import androidx.room.Query
|
||||
import androidx.room.Transaction
|
||||
|
|
@ -16,6 +17,9 @@ interface PacketDao {
|
|||
@Query("Select * from packet order by received_time asc")
|
||||
fun getAllPackets(): Flow<List<Packet>>
|
||||
|
||||
@Query("Select * from packet where port_num = 1 order by received_time desc")
|
||||
fun getContactKeys(): Flow<Map<@MapColumn(columnName = "contact_key") String, Packet>>
|
||||
|
||||
@Insert
|
||||
fun insert(packet: Packet)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue