From 6bb54bcd5554412111aaa0c9595e2130b59eaab6 Mon Sep 17 00:00:00 2001 From: James Rich <2199651+jamesarich@users.noreply.github.com> Date: Mon, 5 Jan 2026 13:32:25 -0600 Subject: [PATCH] fix: reaction display regression (#4141) Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com> --- .../mesh/service/MeshActionHandler.kt | 2 +- .../geeksville/mesh/service/MeshDataHandler.kt | 9 +++++++-- .../core/data/repository/NodeRepository.kt | 11 +++++------ .../feature/messaging/MessageListPaged.kt | 4 +++- .../feature/messaging/component/Reaction.kt | 17 +++++++++++++---- 5 files changed, 29 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/com/geeksville/mesh/service/MeshActionHandler.kt b/app/src/main/java/com/geeksville/mesh/service/MeshActionHandler.kt index a2235eee4..b488c237d 100644 --- a/app/src/main/java/com/geeksville/mesh/service/MeshActionHandler.kt +++ b/app/src/main/java/com/geeksville/mesh/service/MeshActionHandler.kt @@ -130,7 +130,7 @@ constructor( val reaction = ReactionEntity( replyId = action.replyId, - userId = DataPacket.ID_LOCAL, + userId = nodeManager.getMyId(), emoji = action.emoji, timestamp = System.currentTimeMillis(), snr = 0f, diff --git a/app/src/main/java/com/geeksville/mesh/service/MeshDataHandler.kt b/app/src/main/java/com/geeksville/mesh/service/MeshDataHandler.kt index c39b071da..d609ebe50 100644 --- a/app/src/main/java/com/geeksville/mesh/service/MeshDataHandler.kt +++ b/app/src/main/java/com/geeksville/mesh/service/MeshDataHandler.kt @@ -494,8 +494,13 @@ constructor( } } - private fun getSenderName(packet: DataPacket): String = - nodeManager.nodeDBbyID[packet.from]?.user?.longName ?: getString(Res.string.unknown_username) + private fun getSenderName(packet: DataPacket): String { + if (packet.from == DataPacket.ID_LOCAL) { + val myId = nodeManager.getMyId() + return nodeManager.nodeDBbyID[myId]?.user?.longName ?: getString(Res.string.unknown_username) + } + return nodeManager.nodeDBbyID[packet.from]?.user?.longName ?: getString(Res.string.unknown_username) + } private suspend fun updateNotification(contactKey: String, dataPacket: DataPacket) { when (dataPacket.dataType) { diff --git a/core/data/src/main/kotlin/org/meshtastic/core/data/repository/NodeRepository.kt b/core/data/src/main/kotlin/org/meshtastic/core/data/repository/NodeRepository.kt index 6453b3069..781259892 100644 --- a/core/data/src/main/kotlin/org/meshtastic/core/data/repository/NodeRepository.kt +++ b/core/data/src/main/kotlin/org/meshtastic/core/data/repository/NodeRepository.kt @@ -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 . */ - package org.meshtastic.core.data.repository import androidx.lifecycle.Lifecycle @@ -109,15 +108,15 @@ constructor( ?: MeshProtos.User.newBuilder() .setId(userId) .setLongName( - if (userId == "^local") { - "Local" + if (userId == DataPacket.ID_LOCAL) { + ourNodeInfo.value?.user?.longName ?: "Local" } else { "Meshtastic ${userId.takeLast(n = 4)}" }, ) .setShortName( - if (userId == "^local") { - "Local" + if (userId == DataPacket.ID_LOCAL) { + ourNodeInfo.value?.user?.shortName ?: "Local" } else { userId.takeLast(n = 4) }, diff --git a/feature/messaging/src/main/kotlin/org/meshtastic/feature/messaging/MessageListPaged.kt b/feature/messaging/src/main/kotlin/org/meshtastic/feature/messaging/MessageListPaged.kt index ed17ec107..acfcdc074 100644 --- a/feature/messaging/src/main/kotlin/org/meshtastic/feature/messaging/MessageListPaged.kt +++ b/feature/messaging/src/main/kotlin/org/meshtastic/feature/messaging/MessageListPaged.kt @@ -129,7 +129,9 @@ internal fun MessageListPaged( } var showReactionDialog by remember { mutableStateOf?>(null) } - showReactionDialog?.let { reactions -> ReactionDialog(reactions) { showReactionDialog = null } } + showReactionDialog?.let { reactions -> + ReactionDialog(reactions = reactions, myId = state.ourNode?.user?.id, onDismiss = { showReactionDialog = null }) + } val coroutineScope = rememberCoroutineScope() diff --git a/feature/messaging/src/main/kotlin/org/meshtastic/feature/messaging/component/Reaction.kt b/feature/messaging/src/main/kotlin/org/meshtastic/feature/messaging/component/Reaction.kt index 9cb2e903a..2e871289f 100644 --- a/feature/messaging/src/main/kotlin/org/meshtastic/feature/messaging/component/Reaction.kt +++ b/feature/messaging/src/main/kotlin/org/meshtastic/feature/messaging/component/Reaction.kt @@ -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 . */ - package org.meshtastic.feature.messaging.component import androidx.compose.animation.AnimatedVisibility @@ -54,9 +53,11 @@ import androidx.compose.ui.tooling.preview.PreviewLightDark import androidx.compose.ui.unit.dp import org.jetbrains.compose.resources.stringResource import org.meshtastic.core.database.entity.Reaction +import org.meshtastic.core.model.DataPacket import org.meshtastic.core.model.util.getShortDateTime import org.meshtastic.core.strings.Res import org.meshtastic.core.strings.hops_away_template +import org.meshtastic.core.strings.you import org.meshtastic.core.ui.component.BottomSheetDialog import org.meshtastic.core.ui.component.Rssi import org.meshtastic.core.ui.component.Snr @@ -113,8 +114,9 @@ internal fun ReactionRow( private fun reduceEmojis(emojis: List): Map = emojis.groupingBy { it }.eachCount() +@Suppress("LongMethod") @Composable -internal fun ReactionDialog(reactions: List, onDismiss: () -> Unit = {}) = +internal fun ReactionDialog(reactions: List, myId: String? = null, onDismiss: () -> Unit = {}) = BottomSheetDialog(onDismiss = onDismiss, modifier = Modifier.fillMaxHeight(fraction = .3f)) { val groupedEmojis = reactions.groupBy { it.emoji } var selectedEmoji by remember { mutableStateOf(null) } @@ -144,7 +146,14 @@ internal fun ReactionDialog(reactions: List, onDismiss: () -> Unit = { horizontalArrangement = Arrangement.SpaceBetween, verticalAlignment = Alignment.CenterVertically, ) { - Text(text = reaction.user.longName, style = MaterialTheme.typography.titleMedium) + val isLocal = reaction.user.id == myId || reaction.user.id == DataPacket.ID_LOCAL + val displayName = + if (isLocal) { + "${reaction.user.longName} (${stringResource(Res.string.you)})" + } else { + reaction.user.longName + } + Text(text = displayName, style = MaterialTheme.typography.titleMedium) Text(text = reaction.emoji, style = MaterialTheme.typography.titleLarge) } Row(