From 1a48e70af0297c36351d09ce3ac305f3b4fbf12d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Blin?=
 <sebastien.blin@savoirfairelinux.com>
Date: Fri, 27 Mar 2020 15:02:54 -0400
Subject: [PATCH] callmodel: do not hold participants when merging calls

Change-Id: I03fab4ac2268f58ef0f0d129524d351003b41a4b
---
 src/newcallmodel.cpp | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/src/newcallmodel.cpp b/src/newcallmodel.cpp
index e01ce541..8a86e830 100644
--- a/src/newcallmodel.cpp
+++ b/src/newcallmodel.cpp
@@ -425,6 +425,7 @@ NewCallModel::joinCalls(const QString& callIdA, const QString& callIdB) const
         // Unpause conference if conference was not active
         CallManager::instance().unholdConference(conf);
         auto accountCall = call1.type == call::Type::CONFERENCE ? accountIdCall2 : accountIdCall1;
+
         bool joined = CallManager::instance().addParticipant(call, conf);
         if (!joined) {
             qWarning() << "Call: " << call << " couldn't join conference " << conf;
@@ -440,8 +441,10 @@ NewCallModel::joinCalls(const QString& callIdA, const QString& callIdB) const
             } catch (...) {}
         } else
             emit callAddedToConference(call, conf);
-    }
-    else {
+
+        // Remove from pendingConferences_
+        pimpl_->pendingConferences_.erase(call);
+    } else {
         CallManager::instance().joinParticipant(callIdA, callIdB);
         // NOTE: This will trigger slotConferenceCreated.
     }
@@ -617,8 +620,11 @@ NewCallModel::setCurrentCall(const QString& callId) const
         return;
     }
     for (const auto& confId : conferences) {
-        if (callId != confId)
-            CallManager::instance().holdConference(confId);
+        if (callId != confId) {
+            QStringList callList = CallManager::instance().getParticipantList(callId);
+            if (callList.indexOf(callId) == -1)
+                CallManager::instance().holdConference(confId);
+        }
     }
 }
 
@@ -728,7 +734,6 @@ NewCallModelPimpl::slotCallStateChanged(const QString& callId, const QString& st
         auto it = pendingConferences_.find(callId);
         if (it != pendingConferences_.end()) {
             linked.joinCalls(it->second, it->first);
-            pendingConferences_.erase(it);
         }
     }
 }
@@ -800,7 +805,10 @@ NewCallModelPimpl::slotConferenceCreated(const QString& confId)
     QStringList callList = CallManager::instance().getParticipantList(confId);
     foreach(const auto& call, callList) {
         emit linked.callAddedToConference(call, confId);
+        // Remove acll from pendingConferences_
+        pendingConferences_.erase(call);
     }
+
 }
 
 void
-- 
GitLab