feat: support max users in voice channels

This commit is contained in:
infi 2026-08-04 13:20:15 +02:00
parent 6e4740ae49
commit 667449fc0b
2 changed files with 23 additions and 4 deletions

View File

@ -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 &&

View File

@ -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")