mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
feat(db): introduce transactional config installation (#3209)
Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit is contained in:
parent
01290278e9
commit
6c0b2c55a0
4 changed files with 34 additions and 63 deletions
|
|
@ -221,4 +221,11 @@ interface NodeInfoDao {
|
|||
|
||||
@Query("UPDATE nodes SET notes = :notes WHERE num = :num")
|
||||
fun setNodeNotes(num: Int, notes: String)
|
||||
|
||||
@Transaction
|
||||
fun installConfig(mi: MyNodeEntity, nodes: List<NodeEntity>) {
|
||||
clearMyNodeInfo()
|
||||
setMyNodeInfo(mi)
|
||||
putAll(nodes.map { getVerifiedNodeForUpsert(it) })
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ interface MeshPrefs {
|
|||
|
||||
@Singleton
|
||||
class MeshPrefsImpl @Inject constructor(@MeshSharedPreferences private val prefs: SharedPreferences) : MeshPrefs {
|
||||
override var deviceAddress: String? by NullableStringPrefDelegate(prefs, "device_address", null)
|
||||
override var deviceAddress: String? by NullableStringPrefDelegate(prefs, "device_address", NO_DEVICE_SELECTED)
|
||||
|
||||
override fun shouldProvideNodeLocation(nodeNum: Int?): Boolean =
|
||||
prefs.getBoolean(provideLocationKey(nodeNum), false)
|
||||
|
|
@ -45,3 +45,5 @@ class MeshPrefsImpl @Inject constructor(@MeshSharedPreferences private val prefs
|
|||
|
||||
private fun provideLocationKey(nodeNum: Int?) = "provide-location-$nodeNum"
|
||||
}
|
||||
|
||||
private const val NO_DEVICE_SELECTED = "n"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue