From 6ee705e7867c27c7f86c5173f65e1b3f5e1453fb Mon Sep 17 00:00:00 2001 From: Isaac <> Date: Fri, 11 Apr 2025 17:53:56 +0400 Subject: [PATCH] Support Muted by admin in conference --- .../VideoChatActionButtonComponent.swift | 4 +-- .../Sources/VideoChatMicButtonComponent.swift | 27 +++++++++++++------ .../Sources/VideoChatScreen.swift | 7 +++-- 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/submodules/TelegramCallsUI/Sources/VideoChatActionButtonComponent.swift b/submodules/TelegramCallsUI/Sources/VideoChatActionButtonComponent.swift index 5a68054ee1..5879d044a0 100644 --- a/submodules/TelegramCallsUI/Sources/VideoChatActionButtonComponent.swift +++ b/submodules/TelegramCallsUI/Sources/VideoChatActionButtonComponent.swift @@ -65,9 +65,9 @@ final class VideoChatActionButtonComponent: Component { } } - enum MicrophoneState { + enum MicrophoneState: Equatable { case connecting - case muted + case muted(forced: Bool) case unmuted case raiseHand case scheduled diff --git a/submodules/TelegramCallsUI/Sources/VideoChatMicButtonComponent.swift b/submodules/TelegramCallsUI/Sources/VideoChatMicButtonComponent.swift index 80c340ef08..4a057d4354 100644 --- a/submodules/TelegramCallsUI/Sources/VideoChatMicButtonComponent.swift +++ b/submodules/TelegramCallsUI/Sources/VideoChatMicButtonComponent.swift @@ -182,7 +182,7 @@ final class VideoChatMicButtonComponent: Component { enum Content: Equatable { case connecting - case muted + case muted(forced: Bool) case unmuted(pushToTalk: Bool) case raiseHand(isRaised: Bool) case scheduled(state: ScheduledState) @@ -263,9 +263,13 @@ final class VideoChatMicButtonComponent: Component { switch component.content { case .connecting, .unmuted, .raiseHand, .scheduled: self.beginTrackingWasPushToTalk = false - case .muted: - self.beginTrackingWasPushToTalk = true - component.updateUnmutedStateIsPushToTalk(true) + case let .muted(forced): + if forced { + self.beginTrackingWasPushToTalk = false + } else { + self.beginTrackingWasPushToTalk = true + component.updateUnmutedStateIsPushToTalk(true) + } } } @@ -291,8 +295,11 @@ final class VideoChatMicButtonComponent: Component { switch component.content { case .connecting: break - case .muted: - component.updateUnmutedStateIsPushToTalk(false) + case let .muted(forced): + if forced { + } else { + component.updateUnmutedStateIsPushToTalk(false) + } case .unmuted: if self.beginTrackingWasPushToTalk { if timestamp < self.beginTrackingTimestamp + 0.15 { @@ -340,8 +347,12 @@ final class VideoChatMicButtonComponent: Component { case .connecting: titleText = component.strings.VoiceChat_Connecting isEnabled = false - case .muted: - titleText = component.strings.VoiceChat_Unmute + case let .muted(forced): + if forced { + titleText = component.strings.VoiceChat_MutedByAdmin + } else { + titleText = component.strings.VoiceChat_Unmute + } case let .unmuted(isPushToTalk): titleText = isPushToTalk ? component.strings.VoiceChat_Live : component.strings.VoiceChat_Mute case let .raiseHand(isRaised): diff --git a/submodules/TelegramCallsUI/Sources/VideoChatScreen.swift b/submodules/TelegramCallsUI/Sources/VideoChatScreen.swift index 906d5277ad..dab1867904 100644 --- a/submodules/TelegramCallsUI/Sources/VideoChatScreen.swift +++ b/submodules/TelegramCallsUI/Sources/VideoChatScreen.swift @@ -2553,9 +2553,12 @@ final class VideoChatScreenComponent: Component { micButtonContent = .unmuted(pushToTalk: self.isPushToTalkActive) actionButtonMicrophoneState = .unmuted } else { - micButtonContent = .muted - actionButtonMicrophoneState = .muted + micButtonContent = .muted(forced: false) + actionButtonMicrophoneState = .muted(forced: false) } + } else if isConference { + micButtonContent = .muted(forced: true) + actionButtonMicrophoneState = .muted(forced: true) } else { micButtonContent = .raiseHand(isRaised: callState.raisedHand) actionButtonMicrophoneState = .raiseHand