From c0532c53d1b1917d778a2139d4a915a998c804ce Mon Sep 17 00:00:00 2001
From: kkostiuk <kateryna.kostiuk@savoirfairelinux.com>
Date: Mon, 18 Jan 2021 16:50:06 -0500
Subject: [PATCH] fix conference layout

Change-Id: Ica47f7a6baffc3952356ad569302acc035b2fdff
---
 src/CurrentCallVC.mm | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/src/CurrentCallVC.mm b/src/CurrentCallVC.mm
index 71297e6b..4f8fd922 100644
--- a/src/CurrentCallVC.mm
+++ b/src/CurrentCallVC.mm
@@ -239,7 +239,7 @@ CVPixelBufferRef pixelBufferPreview;
             return;
         }
         if ([self isCurrentCall: confId]) {
-            [self updateConference: confId];
+            [self updateConference];
         }
     });
     //monitor for updated call state
@@ -385,8 +385,9 @@ CVPixelBufferRef pixelBufferPreview;
     participantsOverlays = [[NSMutableDictionary alloc] init];
 }
 
--(void)updateConference:(QString)confId
+-(void)updateConference
 {
+    auto confId = [self getcallID];
     if (confId.isEmpty()) {
         [self removeConferenceLayout];
         return;
@@ -400,6 +401,7 @@ CVPixelBufferRef pixelBufferPreview;
         [self removeConferenceLayout];
         return;
     }
+    NSMutableArray* participantUrs = [[NSMutableArray alloc] init];
     for (auto participant: participants) {
         ConferenceParticipant conferenceParticipant;
         conferenceParticipant.x = participant["x"].toFloat();
@@ -407,6 +409,7 @@ CVPixelBufferRef pixelBufferPreview;
         conferenceParticipant.width = participant["w"].toFloat();
         conferenceParticipant.hight = participant["h"].toFloat();
         conferenceParticipant.uri = participant["uri"].toNSString();
+        [participantUrs addObject:participant["uri"].toNSString()];
         conferenceParticipant.active = participant["active"] == "true";
         conferenceParticipant.isLocal = false;
         conferenceParticipant.bestName = participant["uri"].toNSString();
@@ -433,6 +436,13 @@ CVPixelBufferRef pixelBufferPreview;
             [overlay updateViewWithParticipant: conferenceParticipant];
         }
     }
+    auto keys = [participantsOverlays allKeys];
+    for (auto key : keys) {
+        if (![participantUrs containsObject:key]) {
+            [participantsOverlays[key] removeFromSuperview];
+            participantsOverlays[key] = nil;
+        }
+    }
 }
 
 -(void) updateCall
@@ -465,7 +475,7 @@ CVPixelBufferRef pixelBufferPreview;
     [recordOnOffButton setHidden:!confUid_.isEmpty()];
     [holdOnOffButton setHidden:!confUid_.isEmpty()];
     [movableBaseForView setHidden:!confUid_.isEmpty()];
-    [self updateConference: confUid_];
+    [self updateConference];
 
     [timeSpentLabel setStringValue:callModel->getFormattedCallDuration(callUid_).toNSString()];
     if (refreshDurationTimer == nil)
-- 
GitLab