mirror of
https://github.com/permissionlesstech/bitchat-android.git
synced 2026-09-19 04:59:59 +00:00
Fix geohash join channel routing
This commit is contained in:
parent
aaac810f4f
commit
83eaebc357
@ -1,5 +1,6 @@
|
|||||||
package com.bitchat.android.ui
|
package com.bitchat.android.ui
|
||||||
|
|
||||||
|
import com.bitchat.android.geohash.ChannelID
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import java.security.MessageDigest
|
import java.security.MessageDigest
|
||||||
@ -16,7 +17,8 @@ class ChannelManager(
|
|||||||
private val state: ChatState,
|
private val state: ChatState,
|
||||||
private val messageManager: MessageManager,
|
private val messageManager: MessageManager,
|
||||||
private val dataManager: DataManager,
|
private val dataManager: DataManager,
|
||||||
private val coroutineScope: CoroutineScope
|
private val coroutineScope: CoroutineScope,
|
||||||
|
private val onSwitchToMeshLocation: () -> Unit = {}
|
||||||
) {
|
) {
|
||||||
|
|
||||||
// Channel encryption and security
|
// Channel encryption and security
|
||||||
@ -109,6 +111,8 @@ class ChannelManager(
|
|||||||
fun switchToChannel(channel: String?) {
|
fun switchToChannel(channel: String?) {
|
||||||
state.setCurrentChannel(channel)
|
state.setCurrentChannel(channel)
|
||||||
state.setSelectedPrivateChatPeer(null)
|
state.setSelectedPrivateChatPeer(null)
|
||||||
|
state.setSelectedLocationChannel(ChannelID.Mesh)
|
||||||
|
onSwitchToMeshLocation()
|
||||||
|
|
||||||
// Clear unread count
|
// Clear unread count
|
||||||
channel?.let { ch ->
|
channel?.let { ch ->
|
||||||
|
|||||||
@ -121,7 +121,17 @@ class ChatViewModel(
|
|||||||
private val conversationListPreferences =
|
private val conversationListPreferences =
|
||||||
com.bitchat.android.services.ConversationListPreferences.getInstance(getApplication())
|
com.bitchat.android.services.ConversationListPreferences.getInstance(getApplication())
|
||||||
private val messageManager = MessageManager(state)
|
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
|
// Create Noise session delegate for clean dependency injection
|
||||||
private val noiseSessionDelegate = object : NoiseSessionDelegate {
|
private val noiseSessionDelegate = object : NoiseSessionDelegate {
|
||||||
|
|||||||
@ -161,4 +161,22 @@ class CommandProcessorTest() {
|
|||||||
)
|
)
|
||||||
assertEquals(0, chatState.getMessagesValue().size)
|
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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2147,6 +2147,9 @@
|
|||||||
<artifact name="aapt2-9.3.1-15703166-osx.jar">
|
<artifact name="aapt2-9.3.1-15703166-osx.jar">
|
||||||
<sha256 value="1e35bc2ce18c3aae840be2a29659ce50d6043e907a44d98ee1cf375d044fa29c" origin="Generated by Gradle"/>
|
<sha256 value="1e35bc2ce18c3aae840be2a29659ce50d6043e907a44d98ee1cf375d044fa29c" origin="Generated by Gradle"/>
|
||||||
</artifact>
|
</artifact>
|
||||||
|
<artifact name="aapt2-9.3.1-15703166-windows.jar">
|
||||||
|
<sha256 value="b1006ecec7e5936257e95e97f3eba7ef439d3e44178967cc048f86c9119fb231" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
<artifact name="aapt2-9.3.1-15703166.pom">
|
<artifact name="aapt2-9.3.1-15703166.pom">
|
||||||
<sha256 value="edb82dcbe738ca78b31612cb307bf99e5f02f25c8125048f933e792fd7778beb" origin="Generated by Gradle"/>
|
<sha256 value="edb82dcbe738ca78b31612cb307bf99e5f02f25c8125048f933e792fd7778beb" origin="Generated by Gradle"/>
|
||||||
</artifact>
|
</artifact>
|
||||||
@ -4903,6 +4906,9 @@
|
|||||||
</artifact>
|
</artifact>
|
||||||
</component>
|
</component>
|
||||||
<component group="org.junit" name="junit-bom" version="5.9.2">
|
<component group="org.junit" name="junit-bom" version="5.9.2">
|
||||||
|
<artifact name="junit-bom-5.9.2.module">
|
||||||
|
<sha256 value="ab137ba5a8e32c9b066bf9126a1c76dd5614b724ba5c0b02549772b5e9f4cf1f" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
<artifact name="junit-bom-5.9.2.pom">
|
<artifact name="junit-bom-5.9.2.pom">
|
||||||
<sha256 value="2ed07d65845131f5336a86476c9a4056b59d0b58b9815ab3679bb0f36f35f705" origin="Generated by Gradle"/>
|
<sha256 value="2ed07d65845131f5336a86476c9a4056b59d0b58b9815ab3679bb0f36f35f705" origin="Generated by Gradle"/>
|
||||||
</artifact>
|
</artifact>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user