Merge pull request #2394 from vitorpamplona/claude/merge-mls-groups-LHMHG

Add MarmotGroup chat room support to ChatroomHeaderCompose
This commit is contained in:
Vitor Pamplona
2026-04-15 08:02:23 -04:00
committed by GitHub
2 changed files with 37 additions and 0 deletions
@@ -42,6 +42,7 @@ import androidx.compose.ui.text.withStyle
import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.vitorpamplona.amethyst.R import com.vitorpamplona.amethyst.R
import com.vitorpamplona.amethyst.commons.model.emphChat.EphemeralChatChannel import com.vitorpamplona.amethyst.commons.model.emphChat.EphemeralChatChannel
import com.vitorpamplona.amethyst.commons.model.marmotGroups.MarmotGroupChatroom
import com.vitorpamplona.amethyst.commons.model.nip28PublicChats.PublicChatChannel import com.vitorpamplona.amethyst.commons.model.nip28PublicChats.PublicChatChannel
import com.vitorpamplona.amethyst.model.Note import com.vitorpamplona.amethyst.model.Note
import com.vitorpamplona.amethyst.model.User import com.vitorpamplona.amethyst.model.User
@@ -118,6 +119,12 @@ private fun ChatroomEntry(
accountViewModel: AccountViewModel, accountViewModel: AccountViewModel,
nav: INav, nav: INav,
) { ) {
val marmotGroup = lastMessage.inGatherers?.firstNotNullOfOrNull { it as? MarmotGroupChatroom }
if (marmotGroup != null) {
MarmotGroupRoomCompose(lastMessage, marmotGroup, accountViewModel, nav)
return
}
val baseNoteEvent = lastMessage.event val baseNoteEvent = lastMessage.event
when (baseNoteEvent) { when (baseNoteEvent) {
is ChannelMessageEvent -> { is ChannelMessageEvent -> {
@@ -234,6 +241,35 @@ private fun ChannelRoomCompose(
) )
} }
@Composable
private fun MarmotGroupRoomCompose(
lastMessage: Note,
chatroom: MarmotGroupChatroom,
accountViewModel: AccountViewModel,
nav: INav,
) {
val authorName by observeUserName(lastMessage.author!!, accountViewModel)
val displayName by chatroom.displayName.collectAsStateWithLifecycle()
val unread by chatroom.unreadCount.collectAsStateWithLifecycle()
val noteEvent = lastMessage.event
val description = noteEvent?.content?.take(200)
val groupName = displayName?.takeIf { it.isNotBlank() } ?: "Group ${chatroom.nostrGroupId.take(8)}"
ChannelName(
channelIdHex = chatroom.nostrGroupId,
channelPicture = null,
channelTitle = { modifier -> ChannelTitleWithLabelInfo(groupName, R.string.marmot_group, modifier) },
channelLastTime = lastMessage.createdAt(),
channelLastContent = "$authorName: $description",
hasNewMessages = unread > 0,
loadProfilePicture = accountViewModel.settings.showProfilePictures(),
loadRobohash = accountViewModel.settings.isNotPerformanceMode(),
onClick = { nav.nav(Route.MarmotGroupChat(chatroom.nostrGroupId)) },
)
}
@Composable @Composable
private fun ChannelTitleWithLabelInfo( private fun ChannelTitleWithLabelInfo(
channelName: String, channelName: String,
+1
View File
@@ -283,6 +283,7 @@
and thus chat messages disappear over time</string> and thus chat messages disappear over time</string>
<string name="public_chat">Public Chat</string> <string name="public_chat">Public Chat</string>
<string name="marmot_group">MLS Group</string>
<string name="public_chat_title">Public Chat Metadata</string> <string name="public_chat_title">Public Chat Metadata</string>
<string name="public_chat_explainer">Public chats are visible to everyone on Nostr and anyone <string name="public_chat_explainer">Public chats are visible to everyone on Nostr and anyone
can participate on them. They are great for open communities around specific topics. can participate on them. They are great for open communities around specific topics.