Support Muted by admin in conference

This commit is contained in:
Isaac 2025-04-11 17:53:56 +04:00
parent dcde323740
commit 6ee705e786
3 changed files with 26 additions and 12 deletions

View File

@ -65,9 +65,9 @@ final class VideoChatActionButtonComponent: Component {
} }
} }
enum MicrophoneState { enum MicrophoneState: Equatable {
case connecting case connecting
case muted case muted(forced: Bool)
case unmuted case unmuted
case raiseHand case raiseHand
case scheduled case scheduled

View File

@ -182,7 +182,7 @@ final class VideoChatMicButtonComponent: Component {
enum Content: Equatable { enum Content: Equatable {
case connecting case connecting
case muted case muted(forced: Bool)
case unmuted(pushToTalk: Bool) case unmuted(pushToTalk: Bool)
case raiseHand(isRaised: Bool) case raiseHand(isRaised: Bool)
case scheduled(state: ScheduledState) case scheduled(state: ScheduledState)
@ -263,11 +263,15 @@ final class VideoChatMicButtonComponent: Component {
switch component.content { switch component.content {
case .connecting, .unmuted, .raiseHand, .scheduled: case .connecting, .unmuted, .raiseHand, .scheduled:
self.beginTrackingWasPushToTalk = false self.beginTrackingWasPushToTalk = false
case .muted: case let .muted(forced):
if forced {
self.beginTrackingWasPushToTalk = false
} else {
self.beginTrackingWasPushToTalk = true self.beginTrackingWasPushToTalk = true
component.updateUnmutedStateIsPushToTalk(true) component.updateUnmutedStateIsPushToTalk(true)
} }
} }
}
return super.beginTracking(touch, with: event) return super.beginTracking(touch, with: event)
} }
@ -291,8 +295,11 @@ final class VideoChatMicButtonComponent: Component {
switch component.content { switch component.content {
case .connecting: case .connecting:
break break
case .muted: case let .muted(forced):
if forced {
} else {
component.updateUnmutedStateIsPushToTalk(false) component.updateUnmutedStateIsPushToTalk(false)
}
case .unmuted: case .unmuted:
if self.beginTrackingWasPushToTalk { if self.beginTrackingWasPushToTalk {
if timestamp < self.beginTrackingTimestamp + 0.15 { if timestamp < self.beginTrackingTimestamp + 0.15 {
@ -340,8 +347,12 @@ final class VideoChatMicButtonComponent: Component {
case .connecting: case .connecting:
titleText = component.strings.VoiceChat_Connecting titleText = component.strings.VoiceChat_Connecting
isEnabled = false isEnabled = false
case .muted: case let .muted(forced):
if forced {
titleText = component.strings.VoiceChat_MutedByAdmin
} else {
titleText = component.strings.VoiceChat_Unmute titleText = component.strings.VoiceChat_Unmute
}
case let .unmuted(isPushToTalk): case let .unmuted(isPushToTalk):
titleText = isPushToTalk ? component.strings.VoiceChat_Live : component.strings.VoiceChat_Mute titleText = isPushToTalk ? component.strings.VoiceChat_Live : component.strings.VoiceChat_Mute
case let .raiseHand(isRaised): case let .raiseHand(isRaised):

View File

@ -2553,9 +2553,12 @@ final class VideoChatScreenComponent: Component {
micButtonContent = .unmuted(pushToTalk: self.isPushToTalkActive) micButtonContent = .unmuted(pushToTalk: self.isPushToTalkActive)
actionButtonMicrophoneState = .unmuted actionButtonMicrophoneState = .unmuted
} else { } else {
micButtonContent = .muted micButtonContent = .muted(forced: false)
actionButtonMicrophoneState = .muted actionButtonMicrophoneState = .muted(forced: false)
} }
} else if isConference {
micButtonContent = .muted(forced: true)
actionButtonMicrophoneState = .muted(forced: true)
} else { } else {
micButtonContent = .raiseHand(isRaised: callState.raisedHand) micButtonContent = .raiseHand(isRaised: callState.raisedHand)
actionButtonMicrophoneState = .raiseHand actionButtonMicrophoneState = .raiseHand