mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
refactor: null safety, update date/time libraries, and migrate tests (#4900)
Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit is contained in:
parent
f826cac6c8
commit
664ebf218e
163 changed files with 503 additions and 4993 deletions
|
|
@ -184,8 +184,9 @@ open class DatabaseManager(
|
|||
val limit = getCurrentCacheLimit()
|
||||
val all = listExistingDbNames()
|
||||
// Only enforce the limit over device-specific DBs; exclude legacy and default DBs
|
||||
val deviceDbs =
|
||||
all.filterNot { it == DatabaseConstants.LEGACY_DB_NAME || it == DatabaseConstants.DEFAULT_DB_NAME }
|
||||
val deviceDbs = all.filterNot {
|
||||
it == DatabaseConstants.LEGACY_DB_NAME || it == DatabaseConstants.DEFAULT_DB_NAME
|
||||
}
|
||||
|
||||
if (deviceDbs.size <= limit) return@withLock
|
||||
val usageSnapshot = deviceDbs.associateWith { lastUsed(it) }
|
||||
|
|
|
|||
|
|
@ -361,21 +361,20 @@ interface PacketDao {
|
|||
|
||||
@Transaction
|
||||
suspend fun setMuteUntil(contacts: List<String>, until: Long) {
|
||||
val contactList =
|
||||
contacts.map { contact ->
|
||||
// Always mute
|
||||
val absoluteMuteUntil =
|
||||
if (until == Long.MAX_VALUE) {
|
||||
Long.MAX_VALUE
|
||||
} else if (until == 0L) { // unmute
|
||||
0L
|
||||
} else {
|
||||
nowMillis + until
|
||||
}
|
||||
val contactList = contacts.map { contact ->
|
||||
// Always mute
|
||||
val absoluteMuteUntil =
|
||||
if (until == Long.MAX_VALUE) {
|
||||
Long.MAX_VALUE
|
||||
} else if (until == 0L) { // unmute
|
||||
0L
|
||||
} else {
|
||||
nowMillis + until
|
||||
}
|
||||
|
||||
getContactSettings(contact)?.copy(muteUntil = absoluteMuteUntil)
|
||||
?: ContactSettings(contact_key = contact, muteUntil = absoluteMuteUntil)
|
||||
}
|
||||
getContactSettings(contact)?.copy(muteUntil = absoluteMuteUntil)
|
||||
?: ContactSettings(contact_key = contact, muteUntil = absoluteMuteUntil)
|
||||
}
|
||||
upsertContactSettings(contactList)
|
||||
}
|
||||
|
||||
|
|
@ -480,10 +479,9 @@ interface PacketDao {
|
|||
val indexMap =
|
||||
oldSettings
|
||||
.mapIndexed { oldIndex, oldChannel ->
|
||||
val pskMatches =
|
||||
newSettings.mapIndexedNotNull { index, channel ->
|
||||
if (channel.psk == oldChannel.psk) index to channel else null
|
||||
}
|
||||
val pskMatches = newSettings.mapIndexedNotNull { index, channel ->
|
||||
if (channel.psk == oldChannel.psk) index to channel else null
|
||||
}
|
||||
|
||||
val newIndex =
|
||||
when {
|
||||
|
|
|
|||
|
|
@ -98,12 +98,9 @@ data class Packet(
|
|||
fun getRelayNode(relayNodeId: Int, nodes: List<Node>, ourNodeNum: Int?): Node? {
|
||||
val relayNodeIdSuffix = relayNodeId and RELAY_NODE_SUFFIX_MASK
|
||||
|
||||
val candidateRelayNodes =
|
||||
nodes.filter {
|
||||
it.num != ourNodeNum &&
|
||||
it.lastHeard != 0 &&
|
||||
(it.num and RELAY_NODE_SUFFIX_MASK) == relayNodeIdSuffix
|
||||
}
|
||||
val candidateRelayNodes = nodes.filter {
|
||||
it.num != ourNodeNum && it.lastHeard != 0 && (it.num and RELAY_NODE_SUFFIX_MASK) == relayNodeIdSuffix
|
||||
}
|
||||
|
||||
val closestRelayNode =
|
||||
if (candidateRelayNodes.size == 1) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue