refactor: getContacts() DAO using Map return type

This commit is contained in:
andrekir 2024-02-11 07:51:41 -03:00
parent 84a8162f5f
commit 1c5e2dbefc
4 changed files with 15 additions and 13 deletions

View file

@ -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()
}

View file

@ -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)