diff --git a/app/src/main/java/com/bitchat/android/ui/ChannelManager.kt b/app/src/main/java/com/bitchat/android/ui/ChannelManager.kt
index 5cc1375c..43bc2085 100644
--- a/app/src/main/java/com/bitchat/android/ui/ChannelManager.kt
+++ b/app/src/main/java/com/bitchat/android/ui/ChannelManager.kt
@@ -1,5 +1,6 @@
package com.bitchat.android.ui
+import com.bitchat.android.geohash.ChannelID
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch
import java.security.MessageDigest
@@ -16,7 +17,8 @@ class ChannelManager(
private val state: ChatState,
private val messageManager: MessageManager,
private val dataManager: DataManager,
- private val coroutineScope: CoroutineScope
+ private val coroutineScope: CoroutineScope,
+ private val onSwitchToMeshLocation: () -> Unit = {}
) {
// Channel encryption and security
@@ -109,6 +111,8 @@ class ChannelManager(
fun switchToChannel(channel: String?) {
state.setCurrentChannel(channel)
state.setSelectedPrivateChatPeer(null)
+ state.setSelectedLocationChannel(ChannelID.Mesh)
+ onSwitchToMeshLocation()
// Clear unread count
channel?.let { ch ->
diff --git a/app/src/main/java/com/bitchat/android/ui/ChatViewModel.kt b/app/src/main/java/com/bitchat/android/ui/ChatViewModel.kt
index bf9e2f7c..f40549b6 100644
--- a/app/src/main/java/com/bitchat/android/ui/ChatViewModel.kt
+++ b/app/src/main/java/com/bitchat/android/ui/ChatViewModel.kt
@@ -140,7 +140,17 @@ class ChatViewModel(
private val conversationListPreferences =
com.bitchat.android.services.ConversationListPreferences.getInstance(getApplication())
private val messageManager = MessageManager(state)
- private val channelManager = ChannelManager(state, messageManager, dataManager, viewModelScope)
+ private val channelManager = ChannelManager(
+ state,
+ messageManager,
+ dataManager,
+ viewModelScope,
+ onSwitchToMeshLocation = {
+ com.bitchat.android.geohash.LocationChannelManager
+ .getInstance(getApplication())
+ .select(com.bitchat.android.geohash.ChannelID.Mesh)
+ }
+ )
// Create Noise session delegate for clean dependency injection
private val noiseSessionDelegate = object : NoiseSessionDelegate {
diff --git a/app/src/test/java/com/bitchat/android/ui/CommandProcessorTest.kt b/app/src/test/java/com/bitchat/android/ui/CommandProcessorTest.kt
index 36c68429..2ed944fe 100644
--- a/app/src/test/java/com/bitchat/android/ui/CommandProcessorTest.kt
+++ b/app/src/test/java/com/bitchat/android/ui/CommandProcessorTest.kt
@@ -163,6 +163,23 @@ class CommandProcessorTest() {
assertEquals(0, chatState.getMessagesValue().size)
}
+ @Test
+ fun `join command leaves active geohash selection for mesh channel routing`() {
+ chatState.setSelectedLocationChannel(
+ ChannelID.Location(GeohashChannel(GeohashChannelLevel.REGION, "9q"))
+ )
+
+ commandProcessor.processCommand(
+ command = "/join backchannel",
+ meshService = meshService,
+ myPeerID = "peer-id",
+ onSendMessage = { _, _, _ -> },
+ viewModel = null
+ )
+
+ assertEquals("#backchannel", chatState.getCurrentChannelValue())
+ assertEquals(ChannelID.Mesh, chatState.selectedLocationChannel.value)
+
@Test
fun `clearSuggestions hides the command suggestion popup`() {
// Typing "/" opens the command popup.
@@ -187,5 +204,6 @@ class CommandProcessorTest() {
commandProcessor.clearSuggestions()
assertFalse(chatState.getShowMentionSuggestionsValue())
assertTrue(chatState.getMentionSuggestionsValue().isEmpty())
+
}
}
diff --git a/gradle/verification-metadata.xml b/gradle/verification-metadata.xml
index a62cbff6..08eb23c4 100644
--- a/gradle/verification-metadata.xml
+++ b/gradle/verification-metadata.xml
@@ -2147,6 +2147,9 @@
+
+
+
@@ -4903,6 +4906,9 @@
+
+
+