From 667449fc0b9ac6cde450a477f8821bf7cc349194 Mon Sep 17 00:00:00 2001 From: infi Date: Tue, 4 Aug 2026 13:20:15 +0200 Subject: [PATCH] feat: support max users in voice channels --- .../screens/chat/drawer/ChannelSideDrawer.kt | 18 ++++++++++++++++-- .../chat/stoat/core/model/schemas/Channel.kt | 9 +++++++-- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/chat/stoat/composables/screens/chat/drawer/ChannelSideDrawer.kt b/app/src/main/java/chat/stoat/composables/screens/chat/drawer/ChannelSideDrawer.kt index 3229f500..5475c86f 100644 --- a/app/src/main/java/chat/stoat/composables/screens/chat/drawer/ChannelSideDrawer.kt +++ b/app/src/main/java/chat/stoat/composables/screens/chat/drawer/ChannelSideDrawer.kt @@ -103,6 +103,7 @@ import chat.stoat.core.model.util.UserVoiceState import chat.stoat.screens.chat.ChatRouterDestination import chat.stoat.screens.chat.LocalIsConnected import chat.stoat.sheets.ChannelContextSheet +import chat.stoat.ui.theme.FragmentMono import kotlinx.coroutines.CancellationException import kotlinx.coroutines.launch import kotlinx.coroutines.supervisorScope @@ -957,10 +958,10 @@ fun ChannelItem( }, style = MaterialTheme.typography.bodyMedium, maxLines = 1, - overflow = TextOverflow.Ellipsis + overflow = TextOverflow.Ellipsis, + modifier = Modifier.weight(1f) ) if (hasUnread && !isCurrent) { - Spacer(Modifier.weight(1f)) Box( Modifier .clip(CircleShape) @@ -968,6 +969,19 @@ fun ChannelItem( .requiredSize(8.dp) ) } + channel.voice?.maxUsers?.let { maxUsers -> + val participantCount = channel.id + ?.let { StoatAPI.voiceStateCache[it]?.participants?.size } + ?: 0 + Text( + text = "$participantCount/$maxUsers", + style = MaterialTheme.typography.bodySmall.copy( + fontFamily = FragmentMono + ), + color = LocalContentColor.current.copy(alpha = 0.7f), + maxLines = 1 + ) + } } if (showVoiceParticipants && diff --git a/core/model/src/main/java/chat/stoat/core/model/schemas/Channel.kt b/core/model/src/main/java/chat/stoat/core/model/schemas/Channel.kt index e0e21d72..ce46a1a3 100644 --- a/core/model/src/main/java/chat/stoat/core/model/schemas/Channel.kt +++ b/core/model/src/main/java/chat/stoat/core/model/schemas/Channel.kt @@ -9,7 +9,6 @@ import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor import kotlinx.serialization.descriptors.SerialDescriptor import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Encoder -import kotlinx.serialization.json.JsonElement @Serializable data class MessagesInChannel( @@ -78,7 +77,7 @@ data class Channel( @SerialName("default_permissions") val defaultPermissions: PermissionDescription? = null, val nsfw: Boolean? = null, - val voice: JsonElement? = null, + val voice: VoiceInformation? = null, val slowmode: Long? = null, val type: String? = null // this is _only_ used for websocket events! ) { @@ -106,6 +105,12 @@ data class Channel( } } +@Serializable +data class VoiceInformation( + @SerialName("max_users") + val maxUsers: Int? = null +) + @Serializable data class ChannelSlowmode( @SerialName("channel_id")