From 6174c0cbb1e37771c635f2e626ed887ad5551301 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Blin?=
 <sebastien.blin@savoirfairelinux.com>
Date: Thu, 24 Mar 2022 15:25:48 -0400
Subject: [PATCH] participantsoverlay: avoid freeze and async load

Change-Id: I54d7a5c413cf8c1fa5b43ea1f0f03b4ee9fbaf12
GitLab: #476
---
 src/calladapter.cpp                           |  6 ++----
 src/mainview/components/ParticipantsLayer.qml | 15 ++++++++++++++-
 2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/src/calladapter.cpp b/src/calladapter.cpp
index c57c3e5e6..3a4294155 100644
--- a/src/calladapter.cpp
+++ b/src/calladapter.cpp
@@ -478,8 +478,7 @@ CallAdapter::onShowIncomingCallView(const QString& accountId, const QString& con
 void
 CallAdapter::onShowCallView(const QString& accountId, const QString& convUid)
 {
-    updateCall(convUid, accountId);
-    Q_EMIT lrcInstance_->conversationUpdated(convUid, accountId);
+    Q_EMIT lrcInstance_->conversationUpdated(convUid, accountId); // This will show the call
 }
 
 void
@@ -489,8 +488,7 @@ CallAdapter::updateCall(const QString& convUid, const QString& accountId, bool f
         return;
     accountId_ = accountId.isEmpty() ? accountId_ : accountId;
 
-    const auto& convInfo = lrcInstance_->getConversationFromConvUid(
-        lrcInstance_->get_selectedConvUid());
+    const auto& convInfo = lrcInstance_->getConversationFromConvUid(convUid);
     if (convInfo.uid.isEmpty()) {
         return;
     }
diff --git a/src/mainview/components/ParticipantsLayer.qml b/src/mainview/components/ParticipantsLayer.qml
index 879443115..6d0599f05 100644
--- a/src/mainview/components/ParticipantsLayer.qml
+++ b/src/mainview/components/ParticipantsLayer.qml
@@ -192,7 +192,16 @@ Item {
                         model: GenericParticipantsFilterModel
                         delegate: Loader {
                             sourceComponent: callVideoMedia
-                            visible: inLine ? index >= genericParticipantsRect.currentPos && index < genericParticipantsRect.currentPos + genericParticipantsRect.showable : true
+                            active: root.visible
+                            asynchronous: true
+                            visible: {
+                                if (status !== Loader.Ready)
+                                    return false
+                                if (inLine)
+                                    return  index >= genericParticipantsRect.currentPos
+                                            && index < genericParticipantsRect.currentPos + genericParticipantsRect.showable
+                                return true
+                            }
                             width: {
                                 var lastLine = commonParticipants.count % commonParticipantsFlow.columns
                                 var horComponents = ((commonParticipants.count - index) > lastLine || index < 0) ? commonParticipantsFlow.columns : lastLine
@@ -244,7 +253,11 @@ Item {
 
                 model: ActiveParticipantsFilterModel
                 delegate: Loader {
+                    active: root.visible
+                    asynchronous: true
                     sourceComponent: callVideoMedia
+                    visible: status == Loader.Ready
+
                     width: Math.ceil(activeParticipantsFlow.width / activeParticipantsFlow.columns) - activeParticipantsFlow.columnsSpacing
                     height: Math.ceil(activeParticipantsFlow.height / activeParticipantsFlow.rows) - activeParticipantsFlow.rowsSpacing
 
-- 
GitLab