fix(node): Correct owner ID and local user detection (#4256)

Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit is contained in:
James Rich 2026-01-18 21:20:40 -06:00 committed by GitHub
parent f760feffe2
commit 3b0dda4491
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 183 additions and 133 deletions

View file

@ -178,22 +178,6 @@ private fun MapView.updateMarkers(
nodeClusterer.invalidate()
}
// private fun addWeatherLayer() {
// if (map.tileProvider.tileSource.name()
// .equals(CustomTileSource.getTileSource("ESRI World TOPO").name())
// ) {
// val layer = TilesOverlay(
// MapTileProviderBasic(
// activity,
// CustomTileSource.OPENWEATHER_RADAR
// ), context
// )
// layer.loadingBackgroundColor = Color.TRANSPARENT
// layer.loadingLineColor = Color.TRANSPARENT
// map.overlayManager.add(layer)
// }
// }
private fun cacheManagerCallback(onTaskComplete: () -> Unit, onTaskFailed: (Int) -> Unit) =
object : CacheManager.CacheManagerCallback {
override fun onTaskComplete() {
@ -225,7 +209,7 @@ private fun cacheManagerCallback(onTaskComplete: () -> Unit, onTaskFailed: (Int)
* @param navigateToNodeDetails Callback to navigate to the details screen of a selected node.
*/
@OptIn(ExperimentalPermissionsApi::class) // Added for Accompanist
@Suppress("CyclomaticComplexMethod", "LongMethod")
@Suppress("CyclomaticComplexMethod", "LongParameterList", "LongMethod")
@Composable
fun MapView(
mapViewModel: MapViewModel = hiltViewModel(),
@ -336,6 +320,7 @@ fun MapView(
val nodes by mapViewModel.nodes.collectAsStateWithLifecycle()
val waypoints by mapViewModel.waypoints.collectAsStateWithLifecycle(emptyMap())
val selectedWaypointId by mapViewModel.selectedWaypointId.collectAsStateWithLifecycle()
val myId by mapViewModel.myId.collectAsStateWithLifecycle()
LaunchedEffect(selectedWaypointId, waypoints) {
if (selectedWaypointId != null && waypoints.containsKey(selectedWaypointId)) {
@ -506,7 +491,7 @@ fun MapView(
}
}
fun getUsername(id: String?) = if (id == DataPacket.ID_LOCAL) {
fun getUsername(id: String?) = if (id == DataPacket.ID_LOCAL || (myId != null && id == myId)) {
com.meshtastic.core.strings.getString(Res.string.you)
} else {
mapViewModel.getUser(id).longName

View file

@ -65,5 +65,5 @@ constructor(
val applicationId = buildConfigProvider.applicationId
fun getUser(userId: String?) = nodeRepository.getUser(userId ?: DataPacket.ID_BROADCAST)
override fun getUser(userId: String?) = nodeRepository.getUser(userId ?: DataPacket.ID_BROADCAST)
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2025 Meshtastic LLC
* Copyright (c) 2025-2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.meshtastic.feature.map
import android.os.RemoteException
@ -79,6 +78,8 @@ abstract class BaseMapViewModel(
val myNodeNum
get() = myNodeInfo.value?.myNodeNum
val myId = nodeRepository.myId
val nodes: StateFlow<List<Node>> =
nodeRepository
.getNodes()
@ -121,6 +122,8 @@ abstract class BaseMapViewModel(
fun getNodeByNum(nodeNum: Int): Node? = nodeRepository.nodeDBbyNum.value[nodeNum]
open fun getUser(userId: String?): MeshProtos.User = nodeRepository.getUser(userId ?: DataPacket.ID_BROADCAST)
fun getUser(nodeNum: Int): MeshProtos.User = nodeRepository.getUser(nodeNum)
fun getNodeOrFallback(nodeNum: Int): Node = getNodeByNum(nodeNum) ?: Node(num = nodeNum, user = getUser(nodeNum))