From 5fe2af9d5035ab659163f0180d90dc48f4c2ec68 Mon Sep 17 00:00:00 2001 From: Christophe Deschamps Date: Tue, 10 Jan 2023 11:51:54 +0100 Subject: [PATCH] Hide active speaker miniature --- .../Voip/ViewModels/ConferenceViewModel.swift | 24 ++++++++++++------- .../VoipConferenceActiveSpeakerView.swift | 14 +++++++---- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/Classes/Swift/Voip/ViewModels/ConferenceViewModel.swift b/Classes/Swift/Voip/ViewModels/ConferenceViewModel.swift index f7c148240..197b71663 100644 --- a/Classes/Swift/Voip/ViewModels/ConferenceViewModel.swift +++ b/Classes/Swift/Voip/ViewModels/ConferenceViewModel.swift @@ -122,16 +122,16 @@ class ConferenceViewModel { }, onActiveSpeakerParticipantDevice: { (conference: Conference, participantDevice: ParticipantDevice) in Log.i("[Conference] Participant [\(participantDevice.address?.asStringUriOnly())] is currently being displayed as active speaker") - if let device = self.conferenceParticipantDevices.value?.filter ({ - $0.participantDevice.address!.weakEqual(address2: participantDevice.address!) - }).first { - if (device.participantDevice.address?.asString() != self.speakingParticipant.value?.participantDevice.address?.asString()) { - Log.i("[Conference] Found actively speaking participant device") - self.speakingParticipant.value = device - } - } else { - Log.w("[Conference] Participant device [\((participantDevice.address?.asStringUriOnly()).orNil)] is the active speaker but couldn't find it in devices list") + if let device = self.conferenceParticipantDevices.value?.filter ({ + $0.participantDevice.address!.weakEqual(address2: participantDevice.address!) + }).first { + if (device.participantDevice.address?.asString() != self.speakingParticipant.value?.participantDevice.address?.asString()) { + Log.i("[Conference] Found actively speaking participant device") + self.speakingParticipant.value = device } + } else { + Log.w("[Conference] Participant device [\((participantDevice.address?.asStringUriOnly()).orNil)] is the active speaker but couldn't find it in devices list") + } } ) @@ -168,6 +168,12 @@ class ConferenceViewModel { } + func updateActiveSpeakerConferenceParticipantDevices () { + activeSpeakerConferenceParticipantDevices.value = self.conferenceParticipantDevices.value!.filter { data in // Filter me and speaking device + data.isMe != true && speakingParticipant.value?.participantDevice.address?.weakEqual(address2: data.participantDevice.address!) != true + } + } + func notifyAdminStatusChanged(participantData:ConferenceParticipantData) { if let participantName = participantData.participant.address?.addressBookEnhancedDisplayName() { let message = (participantData.participant.isAdmin ? VoipTexts.conference_admin_set : VoipTexts.conference_admin_unset).replacingOccurrences(of: "%s", with: participantName) diff --git a/Classes/Swift/Voip/Views/Fragments/Conference/VoipConferenceActiveSpeakerView.swift b/Classes/Swift/Voip/Views/Fragments/Conference/VoipConferenceActiveSpeakerView.swift index 563dc5119..cd5d33e6f 100644 --- a/Classes/Swift/Voip/Views/Fragments/Conference/VoipConferenceActiveSpeakerView.swift +++ b/Classes/Swift/Voip/Views/Fragments/Conference/VoipConferenceActiveSpeakerView.swift @@ -72,12 +72,16 @@ class VoipConferenceActiveSpeakerView: UIView, UICollectionViewDataSource, UICol } duration.conference = model.conference.value self.remotelyRecording.isRemotelyRecorded = model.isRemotelyRecorded - model.conferenceParticipantDevices.readCurrentAndObserve { value in - model.activeSpeakerConferenceParticipantDevices.value = Array((value!.dropFirst().filter { !$0.isMe } )) + + model.conferenceParticipantDevices.readCurrentAndObserve { _ in + model.updateActiveSpeakerConferenceParticipantDevices() + } + model.speakingParticipant.readCurrentAndObserve { _ in + model.updateActiveSpeakerConferenceParticipantDevices() } model.activeSpeakerConferenceParticipantDevices.readCurrentAndObserve { (_) in self.reloadData() - let otherSpeakersCount = model.activeSpeakerConferenceParticipantDevices.value!.count + let otherSpeakersCount = model.conferenceParticipantDevices.value!.count - 1 self.switchCamera.isHidden = true if (otherSpeakersCount == 0) { self.layoutRotatableElements() @@ -139,7 +143,7 @@ class VoipConferenceActiveSpeakerView: UIView, UICollectionViewDataSource, UICol } } model.speakingParticipant.readCurrentAndObserve { speakingParticipant in - if (model.activeSpeakerConferenceParticipantDevices.value!.count > 1) { + if (model.conferenceParticipantDevices.value!.count - 1 > 1) { speakingParticipant?.videoEnabled.readCurrentAndObserve { video in self.fillActiveSpeakerSpace(data: speakingParticipant,video: video == true) self.muted.isHidden = true @@ -395,7 +399,7 @@ class VoipConferenceActiveSpeakerView: UIView, UICollectionViewDataSource, UICol meGrid.removeConstraints().done() activeSpeakerView.removeConstraints().done() activeSpeakerAvatar.removeConstraints().done() - let otherParticipantsCount = conferenceViewModel?.activeSpeakerConferenceParticipantDevices.value!.count + let otherParticipantsCount = (conferenceViewModel?.conferenceParticipantDevices.value!.count ?? 0) - 1 if ([.landscapeLeft, .landscapeRight].contains( UIDevice.current.orientation)) { if (otherParticipantsCount == 0) { activeSpeakerView.matchParentDimmensions().done()