Fix layout change when reaching more than 6 participants

This commit is contained in:
Christophe Deschamps 2022-11-10 08:28:47 +01:00 committed by Christophe Deschamps
parent 988840d9a9
commit 82704471ac
2 changed files with 13 additions and 9 deletions

View file

@ -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")

View file

@ -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