From f8ed88917095921146b9bd55a938c12cfa740606 Mon Sep 17 00:00:00 2001 From: Codex Date: Tue, 10 Mar 2026 21:07:53 +0300 Subject: [PATCH] fix(android): enforce single active voice player in chat info tab --- .../messenger/ui/chat/ChatScreen.kt | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/android/app/src/main/java/ru/daemonlord/messenger/ui/chat/ChatScreen.kt b/android/app/src/main/java/ru/daemonlord/messenger/ui/chat/ChatScreen.kt index 8e55029..e6ee2fd 100644 --- a/android/app/src/main/java/ru/daemonlord/messenger/ui/chat/ChatScreen.kt +++ b/android/app/src/main/java/ru/daemonlord/messenger/ui/chat/ChatScreen.kt @@ -2996,6 +2996,8 @@ private fun ChatInfoTabContent( return } if (tab == ChatInfoTab.Voice) { + var voiceTabActiveSourceId by remember(entries) { mutableStateOf(null) } + var voiceTabForceStopSourceId by remember(entries) { mutableStateOf(null) } LazyColumn( modifier = Modifier .fillMaxWidth() @@ -3052,11 +3054,28 @@ private fun ChatInfoTabContent( playbackTitle = entry.title, playbackSubtitle = entry.subtitle, messageId = entry.sourceMessageId ?: entry.title.hashCode().toLong(), - onPlaybackChanged = {}, - forceStopAudioSourceId = null, + onPlaybackChanged = { playback -> + if (playback.isPlaying) { + val previous = voiceTabActiveSourceId + if (previous != null && previous != playback.sourceId) { + voiceTabForceStopSourceId = previous + } + voiceTabActiveSourceId = playback.sourceId + } else if (voiceTabActiveSourceId == playback.sourceId) { + voiceTabActiveSourceId = null + } + }, + forceStopAudioSourceId = voiceTabForceStopSourceId, forceToggleAudioSourceId = null, forceCycleSpeedAudioSourceId = null, - onForceStopAudioSourceHandled = {}, + onForceStopAudioSourceHandled = { sourceId -> + if (voiceTabForceStopSourceId == sourceId) { + voiceTabForceStopSourceId = null + } + if (voiceTabActiveSourceId == sourceId) { + voiceTabActiveSourceId = null + } + }, onForceToggleAudioSourceHandled = {}, onForceCycleSpeedAudioSourceHandled = {}, )