fix: replace duplicate packet IDs before sending queue (#646)

This commit is contained in:
Andre K 2023-06-20 08:22:10 -03:00 committed by GitHub
parent 9970ced53b
commit bb3b1eaa85
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 0 deletions

View file

@ -34,6 +34,10 @@ class PacketRepository @Inject constructor(private val packetDaoLazy: dagger.Laz
packetDao.updateMessageStatus(d, m)
}
suspend fun updateMessageId(d: DataPacket, id: Int) = withContext(Dispatchers.IO) {
packetDao.updateMessageId(d, id)
}
suspend fun getDataPacketById(requestId: Int) = withContext(Dispatchers.IO) {
packetDao.getDataPacketById(requestId)
}

View file

@ -48,6 +48,12 @@ interface PacketDao {
findDataPacket(data)?.let { update(it.copy(data = new)) }
}
@Transaction
fun updateMessageId(data: DataPacket, id: Int) {
val new = data.copy(id = id)
findDataPacket(data)?.let { update(it.copy(data = new)) }
}
@Query("Select data from packet order by received_time asc")
fun getDataPackets(): List<DataPacket>