Voice Chat UI fixes

This commit is contained in:
Ilya Laktyushin
2020-12-01 16:14:10 +04:00
parent dae9f1e967
commit 811f6981ca
4 changed files with 32 additions and 41 deletions

View File

@@ -137,19 +137,23 @@ public final class VoiceChatController: ViewController {
}
return signal
|> mapToSignal { value in
if value > 0.0 {
return .single(value)
|> then(.single(0.0) |> delay(0.1, queue: Queue.mainQueue()))
} else {
return .single(value)
}
return .single(value)
}
}
func updateAudioLevels(_ levels: [(PeerId, Float)]) {
func updateAudioLevels(_ levels: [(PeerId, Float)], ignore: Set<PeerId> = Set()) {
var updated = Set<PeerId>()
for (peerId, level) in levels {
if let pipe = self.audioLevels[peerId] {
pipe.putNext(level)
pipe.putNext(max(0.001, level))
updated.insert(peerId)
}
}
if !ignore.isEmpty {
for (peerId, pipe) in self.audioLevels {
if !updated.contains(peerId) && !ignore.contains(peerId) {
pipe.putNext(0.0)
}
}
}
}
@@ -593,7 +597,7 @@ public final class VoiceChatController: ViewController {
guard let strongSelf = self else {
return
}
strongSelf.itemInteraction?.updateAudioLevels(levels)
strongSelf.itemInteraction?.updateAudioLevels(levels, ignore: Set([strongSelf.context.account.peerId]))
})
self.myAudioLevelDisposable = (call.myAudioLevel