mirror of
https://github.com/permissionlesstech/bitchat-android.git
synced 2026-07-25 14:45:22 +00:00
fix geohash livedata wiring (#389)
This commit is contained in:
@@ -74,18 +74,17 @@ fun ChatScreen(viewModel: ChatViewModel) {
|
||||
// Get location channel info for timeline switching
|
||||
val selectedLocationChannel by viewModel.selectedLocationChannel.observeAsState()
|
||||
|
||||
// Determine what messages to show based on current context
|
||||
// Determine what messages to show based on current context (unified timelines)
|
||||
val displayMessages = when {
|
||||
selectedPrivatePeer != null -> privateChats[selectedPrivatePeer] ?: emptyList()
|
||||
currentChannel != null -> channelMessages[currentChannel] ?: emptyList()
|
||||
else -> {
|
||||
val locationChannel = selectedLocationChannel
|
||||
if (locationChannel is com.bitchat.android.geohash.ChannelID.Location) {
|
||||
// For geohash channels, get messages from geohash history
|
||||
val geohash = locationChannel.channel.geohash
|
||||
viewModel.getGeohashMessages(geohash)
|
||||
val geokey = "geo:${locationChannel.channel.geohash}"
|
||||
channelMessages[geokey] ?: emptyList()
|
||||
} else {
|
||||
messages // Mesh/public messages
|
||||
messages // Mesh timeline
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -649,13 +649,6 @@ class ChatViewModel(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get messages for a specific geohash timeline
|
||||
*/
|
||||
fun getGeohashMessages(geohash: String): List<BitchatMessage> {
|
||||
return nostrGeohashService.getGeohashMessages(geohash)
|
||||
}
|
||||
|
||||
/**
|
||||
* Get participant count for a specific geohash (5-minute activity window)
|
||||
*/
|
||||
|
||||
@@ -52,8 +52,18 @@ class MessageManager(private val state: ChatState) {
|
||||
currentChannelMessages[channel] = channelMessageList
|
||||
state.setChannelMessages(currentChannelMessages)
|
||||
|
||||
// Update unread count if not currently in this channel
|
||||
if (state.getCurrentChannelValue() != channel) {
|
||||
// Update unread count if not currently viewing this channel
|
||||
// Consider both classic channels (state.currentChannel) and geohash location channel selection
|
||||
val viewingClassicChannel = state.getCurrentChannelValue() == channel
|
||||
val viewingGeohashChannel = try {
|
||||
if (channel.startsWith("geo:")) {
|
||||
val geo = channel.removePrefix("geo:")
|
||||
val selected = state.selectedLocationChannel.value
|
||||
selected is com.bitchat.android.geohash.ChannelID.Location && selected.channel.geohash.equals(geo, ignoreCase = true)
|
||||
} else false
|
||||
} catch (_: Exception) { false }
|
||||
|
||||
if (!viewingClassicChannel && !viewingGeohashChannel) {
|
||||
val currentUnread = state.getUnreadChannelMessagesValue().toMutableMap()
|
||||
currentUnread[channel] = (currentUnread[channel] ?: 0) + 1
|
||||
state.setUnreadChannelMessages(currentUnread)
|
||||
|
||||
Reference in New Issue
Block a user