mirror of
https://github.com/permissionlesstech/bitchat-android.git
synced 2026-07-24 23:45:19 +00:00
fix: action message routing and duplicate local echo in geohash channels (#374)
* fix: send action messages to correct chat * fix(action): avoid double local echo for action messages in geohash channels When sending /hug or /slap in a location (geohash) channel, CommandProcessor was adding a local echo and then routing to NostrGeohashService, which also adds a local echo. This resulted in duplicate action messages on the sender’s screen. Change: detect when the selectedLocationChannel is a Location and, in that case, skip adding the local echo in CommandProcessor and only call the onSendMessage transport callback (NostrGeohashService will add the echo with proper metadata). Private and mesh (non-location) behavior is unchanged.
This commit is contained in:
@@ -266,9 +266,21 @@ class ChatViewModel(
|
||||
|
||||
// Check for commands
|
||||
if (content.startsWith("/")) {
|
||||
val selectedLocationForCommand = state.selectedLocationChannel.value
|
||||
commandProcessor.processCommand(content, meshService, meshService.myPeerID, { messageContent, mentions, channel ->
|
||||
meshService.sendMessage(messageContent, mentions, channel)
|
||||
}, this)
|
||||
if (selectedLocationForCommand is com.bitchat.android.geohash.ChannelID.Location) {
|
||||
// Route command-generated public messages via Nostr in geohash channels
|
||||
nostrGeohashService.sendGeohashMessage(
|
||||
messageContent,
|
||||
selectedLocationForCommand.channel,
|
||||
meshService.myPeerID,
|
||||
state.getNicknameValue()
|
||||
)
|
||||
} else {
|
||||
// Default: route via mesh
|
||||
meshService.sendMessage(messageContent, mentions, channel)
|
||||
}
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -292,6 +292,10 @@ class CommandProcessor(
|
||||
val targetName = parts[1].removePrefix("@")
|
||||
val actionMessage = "* ${state.getNicknameValue() ?: "someone"} $verb $targetName $object_ *"
|
||||
|
||||
// If we're in a geohash location channel, don't add a local echo here.
|
||||
// NostrGeohashService.sendGeohashMessage() will add the local echo with proper metadata.
|
||||
val isInLocationChannel = state.selectedLocationChannel.value is com.bitchat.android.geohash.ChannelID.Location
|
||||
|
||||
// Send as regular message
|
||||
if (state.getSelectedPrivateChatPeerValue() != null) {
|
||||
val peerID = state.getSelectedPrivateChatPeerValue()!!
|
||||
@@ -304,6 +308,9 @@ class CommandProcessor(
|
||||
) { content, peerIdParam, recipientNicknameParam, messageId ->
|
||||
sendPrivateMessageVia(meshService, content, peerIdParam, recipientNicknameParam, messageId)
|
||||
}
|
||||
} else if (isInLocationChannel) {
|
||||
// Let the transport layer add the echo; just send it out
|
||||
onSendMessage(actionMessage, emptyList(), null)
|
||||
} else {
|
||||
val message = BitchatMessage(
|
||||
sender = state.getNicknameValue() ?: myPeerID,
|
||||
|
||||
Reference in New Issue
Block a user