mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
fix: clear data when changing devices (#1985)
This commit is contained in:
parent
ead0c43381
commit
25ecdc912e
7 changed files with 102 additions and 22 deletions
|
|
@ -31,6 +31,7 @@ import kotlinx.coroutines.flow.mapLatest
|
|||
import kotlinx.coroutines.withContext
|
||||
import javax.inject.Inject
|
||||
|
||||
@Suppress("TooManyFunctions")
|
||||
class MeshLogRepository @Inject constructor(
|
||||
private val meshLogDaoLazy: dagger.Lazy<MeshLogDao>,
|
||||
private val dispatchers: CoroutineDispatchers,
|
||||
|
|
|
|||
|
|
@ -111,12 +111,8 @@ class NodeRepository @Inject constructor(
|
|||
}
|
||||
|
||||
suspend fun installNodeDB(mi: MyNodeEntity, nodes: List<NodeEntity>) = withContext(dispatchers.io) {
|
||||
val isDifferentNode = myNodeInfo.value?.myNodeNum != mi.myNodeNum
|
||||
nodeInfoDao.clearMyNodeInfo()
|
||||
nodeInfoDao.setMyNodeInfo(mi) // set MyNodeEntity first
|
||||
if (isDifferentNode) {
|
||||
nodeInfoDao.clearNodeInfo()
|
||||
}
|
||||
nodeInfoDao.putAll(nodes)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -107,4 +107,8 @@ class PacketRepository @Inject constructor(private val packetDaoLazy: dagger.Laz
|
|||
suspend fun insertReaction(reaction: ReactionEntity) = withContext(Dispatchers.IO) {
|
||||
packetDao.insert(reaction)
|
||||
}
|
||||
|
||||
suspend fun clearPacketDB() = withContext(Dispatchers.IO) {
|
||||
packetDao.deleteAll()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -214,4 +214,7 @@ interface PacketDao {
|
|||
|
||||
@Upsert
|
||||
suspend fun insert(reaction: ReactionEntity)
|
||||
|
||||
@Query("DELETE FROM packet")
|
||||
suspend fun deleteAll()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue