mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2025-12-24 00:07:48 -05:00
fix: loadCachedDb() before backfill to ensure in-mem nodedb isn't stale, show filtered count in nodelist (#3827)
This commit is contained in:
@@ -410,7 +410,7 @@ class MeshService : Service() {
|
||||
}
|
||||
.launchIn(serviceScope)
|
||||
|
||||
loadSettings() // Load our last known node DB
|
||||
loadCachedNodeDB() // Load our last known node DB
|
||||
|
||||
// the rest of our init will happen once we are in radioConnection.onServiceConnected
|
||||
}
|
||||
@@ -482,7 +482,7 @@ class MeshService : Service() {
|
||||
// BEGINNING OF MODEL - FIXME, move elsewhere
|
||||
//
|
||||
|
||||
private fun loadSettings() = serviceScope.handledLaunch {
|
||||
private fun loadCachedNodeDB() = serviceScope.handledLaunch {
|
||||
myNodeInfo = nodeRepository.myNodeInfo.value
|
||||
nodeDBbyNodeNum.putAll(nodeRepository.getNodeDBbyNum().first())
|
||||
// Note: we do not haveNodeDB = true because that means we've got a valid db from a real
|
||||
@@ -2104,7 +2104,9 @@ class MeshService : Service() {
|
||||
} else {
|
||||
newNodes.forEach(::installNodeInfo)
|
||||
newNodes.clear()
|
||||
serviceScope.handledLaunch { nodeRepository.installConfig(myNodeInfo!!, nodeDBbyNodeNum.values.toList()) }
|
||||
// Individual nodes are already upserted to DB via updateNodeInfo->nodeRepository.upsert
|
||||
// Only call installConfig to persist myNodeInfo, not to overwrite all nodes
|
||||
serviceScope.handledLaunch { myNodeInfo?.let { nodeRepository.installConfig(it, emptyList()) } }
|
||||
haveNodeDB = true
|
||||
flushEarlyReceivedPackets("node_info_complete")
|
||||
sendAnalytics()
|
||||
@@ -2310,6 +2312,8 @@ class MeshService : Service() {
|
||||
historyLog { dbSummary }
|
||||
// Do not clear packet DB here; messages are per-device and should persist
|
||||
clearNotifications()
|
||||
// Reload nodes from the newly switched database
|
||||
loadCachedNodeDB()
|
||||
}
|
||||
} else {
|
||||
Timber.d("SetDeviceAddress: Device address is unchanged, ignoring.")
|
||||
|
||||
@@ -774,7 +774,7 @@
|
||||
<string name="modules_unlocked">Modules unlocked</string>
|
||||
<string name="modules_already_unlocked">Modules already unlocked</string>
|
||||
<string name="remote">Remote</string>
|
||||
<string name="node_count_template">(%1$d online / %2$d total)</string>
|
||||
<string name="node_count_template">(%1$d online / %2$d shown / %3$d total)</string>
|
||||
<string name="react">React</string>
|
||||
<string name="disconnect">Disconnect</string>
|
||||
<string name="scanning_bluetooth">Scanning for Bluetooth devices…</string>
|
||||
|
||||
@@ -367,6 +367,7 @@ private fun UpdateUnreadCountPaged(
|
||||
}
|
||||
.debounce(timeoutMillis = UnreadUiDefaults.SCROLL_DEBOUNCE_MILLIS)
|
||||
.collectLatest { index ->
|
||||
// Only mark messages as read if we have a valid index (screen is visible and not scrolling)
|
||||
if (index != null) {
|
||||
val lastUnreadIndex = findLastUnreadMessageIndex(messages)
|
||||
// If we're at/past the oldest unread, mark the first visible unread message
|
||||
|
||||
@@ -122,7 +122,7 @@ fun NodeListScreen(
|
||||
topBar = {
|
||||
MainAppBar(
|
||||
title = stringResource(Res.string.nodes),
|
||||
subtitle = stringResource(Res.string.node_count_template, onlineNodeCount, totalNodeCount),
|
||||
subtitle = stringResource(Res.string.node_count_template, onlineNodeCount, nodes.size, totalNodeCount),
|
||||
ourNode = ourNode,
|
||||
showNodeChip = false,
|
||||
canNavigateUp = false,
|
||||
|
||||
Reference in New Issue
Block a user