diff --git a/Classes/Swift/Voip/ViewModels/ConferenceViewModel.swift b/Classes/Swift/Voip/ViewModels/ConferenceViewModel.swift index 49b6cead1..55d1d2a22 100644 --- a/Classes/Swift/Voip/ViewModels/ConferenceViewModel.swift +++ b/Classes/Swift/Voip/ViewModels/ConferenceViewModel.swift @@ -68,12 +68,6 @@ class ConferenceViewModel { onParticipantAdded: { (conference: Conference, participant: Participant) in Log.i("[Conference] \(conference) Participant \(participant) added") self.updateParticipantsList(conference) - let count = self.conferenceParticipantDevices.value!.count - if (count > self.maxParticipantsForMosaicLayout && conference.currentParams?.videoEnabled == true && conference.call?.currentParams?.conferenceVideoLayout == .Grid) { - Log.w("[Conference] \(conference) More than \(self.maxParticipantsForMosaicLayout) participants \(count), forcing active speaker layout from Grid") - self.conferenceDisplayMode.value = .ActiveSpeaker - self.changeLayout(layout: .ActiveSpeaker) - } }, onParticipantRemoved: {(conference: Conference, participant: Participant) in Log.i("[Conference] \(conference) \(participant) Participant removed") diff --git a/Classes/Swift/Voip/Views/Fragments/Conference/VoipConferenceGridView.swift b/Classes/Swift/Voip/Views/Fragments/Conference/VoipConferenceGridView.swift index b5d1598a4..7043d5478 100644 --- a/Classes/Swift/Voip/Views/Fragments/Conference/VoipConferenceGridView.swift +++ b/Classes/Swift/Voip/Views/Fragments/Conference/VoipConferenceGridView.swift @@ -53,8 +53,15 @@ class VoipConferenceGridView: UIView, UICollectionViewDataSource, UICollectionVi duration.conference = model.conference.value self.remotelyRecording.isRemotelyRecorded = model.isRemotelyRecorded model.conferenceParticipantDevices.clearObservers() - model.conferenceParticipantDevices.readCurrentAndObserve { (_) in - self.reloadData() + model.conferenceParticipantDevices.readCurrentAndObserve { (devices) in + if (devices!.count > model.maxParticipantsForMosaicLayout && model.conference.value?.currentParams?.videoEnabled == true && model.conferenceDisplayMode.value == .Grid) { + Log.w("[Conference] \(model.conference) More than \(model.maxParticipantsForMosaicLayout) participants \(devices!.count), forcing active speaker layout from Grid") + model.conferenceDisplayMode.value = .ActiveSpeaker + model.changeLayout(layout: .ActiveSpeaker) + VoipDialog.toast(message: VoipTexts.conference_too_many_participants_for_mosaic_layout) + } else { + self.reloadData() + } } model.isConferenceLocallyPaused.clearObservers() model.isConferenceLocallyPaused.readCurrentAndObserve { (paused) in @@ -183,7 +190,10 @@ class VoipConferenceGridView: UIView, UICollectionViewDataSource, UICollectionVi func reloadData() { conferenceViewModel?.conferenceParticipantDevices.value?.forEach { $0.clearObservers() - } + } + if let participantCount = conferenceViewModel?.conferenceParticipantDevices.value!.count, participantCount > conferenceViewModel!.maxParticipantsForMosaicLayout { + return + } if (self.isHidden) { self.grid.reloadData() return