Voice Chat UI fixes

This commit is contained in:
Ilya Laktyushin 2020-12-01 14:24:39 +04:00
parent ed28ef6b5b
commit 5f3552ea6f
5 changed files with 20 additions and 6 deletions

View File

@ -265,6 +265,7 @@ public protocol PresentationGroupCall: class {
var members: Signal<PresentationGroupCallMembers?, NoError> { get }
var audioLevels: Signal<[(PeerId, Float)], NoError> { get }
var myAudioLevel: Signal<Float, NoError> { get }
var speakingAudioLevels: Signal<[(PeerId, Float)], NoError> { get }
var isMuted: Signal<Bool, NoError> { get }
func leave(terminateIfPossible: Bool) -> Signal<Bool, NoError>

View File

@ -403,6 +403,7 @@ open class TelegramBaseController: ViewController, KeyShortcutResponder {
if previousTheme !== presentationData.theme || previousStrings !== presentationData.strings {
strongSelf.mediaAccessoryPanel?.0.containerNode.updatePresentationData(presentationData)
strongSelf.locationBroadcastAccessoryPanel?.updatePresentationData(presentationData)
strongSelf.groupCallAccessoryPanel?.updatePresentationData(presentationData)
}
}
})

View File

@ -217,7 +217,7 @@ public final class GroupCallNavigationAccessoryPanel: ASDisplayNode {
}
}
func updatePresentationData(_ presentationData: PresentationData) {
public func updatePresentationData(_ presentationData: PresentationData) {
self.theme = presentationData.theme
self.strings = presentationData.strings

View File

@ -89,6 +89,8 @@ public final class PresentationGroupCallImpl: PresentationGroupCall {
}
}
private let audioLevelsPromise = Promise<[(PeerId, Float)]>()
init() {
}
@ -124,13 +126,23 @@ public final class PresentationGroupCallImpl: PresentationGroupCall {
}
}
var audioLevels: [(PeerId, Float)] = []
for (peerId, speaker) in validSpeakers {
audioLevels.append((peerId, speaker.level))
}
self.participants = validSpeakers
self.speakingParticipants = speakingParticipants
self.audioLevelsPromise.set(.single(audioLevels))
}
func get() -> Signal<Set<PeerId>, NoError> {
return self.speakingParticipantsPromise.get() |> distinctUntilChanged
}
func getAudioLevels() -> Signal<[(PeerId, Float)], NoError> {
return self.audioLevelsPromise.get()
}
}
public let account: Account
@ -189,8 +201,10 @@ public final class PresentationGroupCallImpl: PresentationGroupCall {
}
private var audioLevelsDisposable = MetaDisposable()
private let speakingParticipantsContext = SpeakingParticipantsContext()
public var speakingAudioLevels: Signal<[(PeerId, Float)], NoError> {
return self.speakingParticipantsContext.getAudioLevels()
}
private var participantsContextStateDisposable = MetaDisposable()
private var participantsContext: GroupCallParticipantsContext?

View File

@ -139,12 +139,10 @@ public final class VoiceChatController: ViewController {
|> mapToSignal { value in
if value > 0.0 {
return .single(value)
|> then(.single(0.0) |> delay(1.0, queue: Queue.mainQueue()))
|> then(.single(0.0) |> delay(0.1, queue: Queue.mainQueue()))
} else {
return .single(value)
}
} |> mapToThrottled { next -> Signal<Float, NoError> in
return .single(next) |> then(.complete() |> delay(0.1, queue: Queue.mainQueue()))
}
}
@ -582,7 +580,7 @@ public final class VoiceChatController: ViewController {
}
})
self.audioLevelsDisposable = (call.audioLevels
self.audioLevelsDisposable = (call.speakingAudioLevels
|> deliverOnMainQueue).start(next: { [weak self] levels in
guard let strongSelf = self else {
return