mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
refactor(saveMessagesCSV): use nodeDBbyNum map directly
This commit is contained in:
parent
3a6511b7f9
commit
a6cfbcbfa7
1 changed files with 2 additions and 4 deletions
|
|
@ -560,7 +560,7 @@ class UIViewModel @Inject constructor(
|
||||||
val myNodeNum = myNodeNum ?: return@launch
|
val myNodeNum = myNodeNum ?: return@launch
|
||||||
|
|
||||||
// Capture the current node value while we're still on main thread
|
// Capture the current node value while we're still on main thread
|
||||||
val nodes = nodeDB.nodes.value
|
val nodes = nodeDB.nodeDBbyNum.value
|
||||||
|
|
||||||
val positionToPos: (MeshProtos.Position?) -> Position? = { meshPosition ->
|
val positionToPos: (MeshProtos.Position?) -> Position? = { meshPosition ->
|
||||||
meshPosition?.let { Position(it) }.takeIf {
|
meshPosition?.let { Position(it) }.takeIf {
|
||||||
|
|
@ -569,8 +569,6 @@ class UIViewModel @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
writeToUri(uri) { writer ->
|
writeToUri(uri) { writer ->
|
||||||
// Create a map of nodes keyed by their ID
|
|
||||||
val nodesById = nodes.values.associateBy { it.num }.toMutableMap()
|
|
||||||
val nodePositions = mutableMapOf<Int, MeshProtos.Position?>()
|
val nodePositions = mutableMapOf<Int, MeshProtos.Position?>()
|
||||||
|
|
||||||
writer.appendLine("\"date\",\"time\",\"from\",\"sender name\",\"sender lat\",\"sender long\",\"rx lat\",\"rx long\",\"rx elevation\",\"rx snr\",\"distance\",\"hop limit\",\"payload\"")
|
writer.appendLine("\"date\",\"time\",\"from\",\"sender name\",\"sender lat\",\"sender long\",\"rx lat\",\"rx long\",\"rx elevation\",\"rx snr\",\"distance\",\"hop limit\",\"payload\"")
|
||||||
|
|
@ -599,7 +597,7 @@ class UIViewModel @Inject constructor(
|
||||||
if (proto.rxSnr != 0.0f) {
|
if (proto.rxSnr != 0.0f) {
|
||||||
val rxDateTime = dateFormat.format(packet.received_date)
|
val rxDateTime = dateFormat.format(packet.received_date)
|
||||||
val rxFrom = proto.from.toUInt()
|
val rxFrom = proto.from.toUInt()
|
||||||
val senderName = nodesById[proto.from]?.user?.longName ?: ""
|
val senderName = nodes[proto.from]?.user?.longName ?: ""
|
||||||
|
|
||||||
// sender lat & long
|
// sender lat & long
|
||||||
val senderPosition = nodePositions[proto.from]
|
val senderPosition = nodePositions[proto.from]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue