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:
James Rich 2026-03-23 18:17:50 -05:00 committed by GitHub
parent f826cac6c8
commit 664ebf218e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
163 changed files with 503 additions and 4993 deletions

View file

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

View file

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

View file

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