diff --git a/app/shared/src/commonMain/kotlin/components/SoundContainer.kt b/app/shared/src/commonMain/kotlin/components/SoundContainer.kt index be69940..87fab1a 100644 --- a/app/shared/src/commonMain/kotlin/components/SoundContainer.kt +++ b/app/shared/src/commonMain/kotlin/components/SoundContainer.kt @@ -131,7 +131,7 @@ fun SoundContainer(model: SoundListViewModel) { .scrollable(rememberScrollState(), Orientation.Vertical) ) { items(state.sounds) { group -> - SoundGroup(group, state.playingSound, model::reportError, unavailableFor) + SoundGroup(group, state.playingSound, model::reportError, unavailableFor, !state.canBeStopped) } } } @@ -142,7 +142,8 @@ private fun SoundGroup( group: SoundGroup, playingSound: Id?, errorReporter: ErrorReporter, - unavailableFor: String? + unavailableFor: String?, + disabled: Boolean ) = BoxWithConstraints(Modifier.padding(horizontal = 5.dp)) { val maxWidth = constraints.maxWidth var visible by remember { mutableStateOf(true) } @@ -190,7 +191,7 @@ private fun SoundGroup( description = sound.description, playing = sound.id == playingSound, reportError = errorReporter, - disabled = unavailableFor != null + disabled = unavailableFor != null || disabled ) } } @@ -225,7 +226,7 @@ fun SoundCard( description: String?, playing: Boolean, reportError: ErrorReporter, - disabled: Boolean + disabled: Boolean, ) { val coroutineScope = rememberCoroutineScope { Dispatchers.IO } val corners = RoundedCornerShape(10.dp) diff --git a/app/shared/src/commonMain/kotlin/components/SoundList.kt b/app/shared/src/commonMain/kotlin/components/SoundList.kt index e642e3a..0d85812 100644 --- a/app/shared/src/commonMain/kotlin/components/SoundList.kt +++ b/app/shared/src/commonMain/kotlin/components/SoundList.kt @@ -35,6 +35,7 @@ private val LOG = KotlinLogging.logger {} data class SoundListState( val playingSound: Id? = null, val sounds: List = emptyList(), + val canBeStopped: Boolean = true, val available: Boolean = false, val channelMismatch: Boolean = false, val offline: Boolean = false @@ -87,7 +88,7 @@ class SoundListViewModel( when (event) { is VoiceStateUpdateEvent -> handle(event.voiceState) is InterfaceAvailabilityChangeEvent -> { - _uiState.update { it.copy(available = event.available, playingSound = event.playingSongId) } + _uiState.update { it.copy(available = event.available, playingSound = event.playingSongId, canBeStopped = event.canBeStopped) } } is SoundDeletedEvent -> { @@ -161,7 +162,6 @@ fun SoundList( } } - AnimatedVisibility(!baseState.loading, enter = fadeIn(), exit = fadeOut(), modifier = Modifier.fillMaxSize()) { SoundContainer(model) } diff --git a/bot/src/main/kotlin/dev/schlaubi/tonbrett/bot/core/SoundPlayer.kt b/bot/src/main/kotlin/dev/schlaubi/tonbrett/bot/core/SoundPlayer.kt index e0c57d3..da018ea 100644 --- a/bot/src/main/kotlin/dev/schlaubi/tonbrett/bot/core/SoundPlayer.kt +++ b/bot/src/main/kotlin/dev/schlaubi/tonbrett/bot/core/SoundPlayer.kt @@ -53,7 +53,7 @@ class SoundPlayer(guild: GuildBehavior) : CoroutineScope { locked = !available coroutineScope { getUsersInChannel(channel).forEach { - sendEvent(it, InterfaceAvailabilityChangeEvent(available || it == user, playingSound?.id)) + sendEvent(it, InterfaceAvailabilityChangeEvent(available || it == user, playingSound?.id, playingSound?.isDiscord != true)) } } } diff --git a/common/src/commonMain/kotlin/dev/schlaubi/tonbrett/common/Events.kt b/common/src/commonMain/kotlin/dev/schlaubi/tonbrett/common/Events.kt index f0d76b0..a0e9cc8 100644 --- a/common/src/commonMain/kotlin/dev/schlaubi/tonbrett/common/Events.kt +++ b/common/src/commonMain/kotlin/dev/schlaubi/tonbrett/common/Events.kt @@ -32,10 +32,15 @@ public sealed interface HasSound { * * @property available whether the player is now locked or not * @property playingSongId the id of the sound which is currently playing if any + * @property canBeStopped whether the current sound can be stopped */ @Serializable @SerialName("interface_availability_change") -public data class InterfaceAvailabilityChangeEvent(val available: Boolean, val playingSongId: Id?) : Event +public data class InterfaceAvailabilityChangeEvent( + val available: Boolean, + val playingSongId: Id?, + val canBeStopped: Boolean +) : Event /** * Event indicating that the current users voice state has updated.