From 87acb931b917c54f94f9f6fc6ee30f36a376504f Mon Sep 17 00:00:00 2001
From: Aline Gondim Santos <aline.gondimsantos@savoirfairelinux.com>
Date: Wed, 21 Sep 2022 11:39:34 -0300
Subject: [PATCH] fix: open correct preview when sharing

While in an audio only call, if a sharing is started, the preview could
open the camera instead.

Change-Id: I03d8a9df3385f856f65995a9bbaa1835949d8bdc
---
 src/app/commoncomponents/LocalVideo.qml         | 3 ++-
 src/app/mainview/components/OngoingCallPage.qml | 9 +--------
 2 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/src/app/commoncomponents/LocalVideo.qml b/src/app/commoncomponents/LocalVideo.qml
index caca6c081..5bb34305d 100644
--- a/src/app/commoncomponents/LocalVideo.qml
+++ b/src/app/commoncomponents/LocalVideo.qml
@@ -37,7 +37,8 @@ VideoView {
     }
 
     onVisibleChanged: {
-        const id = visible ? VideoDevices.getDefaultDevice() : ""
+        rendererId = rendererId ? rendererId : VideoDevices.getDefaultDevice()
+        const id = visible ? rendererId : ""
         startWithId(id)
     }
 }
diff --git a/src/app/mainview/components/OngoingCallPage.qml b/src/app/mainview/components/OngoingCallPage.qml
index affad4e69..d57a5d983 100644
--- a/src/app/mainview/components/OngoingCallPage.qml
+++ b/src/app/mainview/components/OngoingCallPage.qml
@@ -199,14 +199,6 @@ Rectangle {
                 visible: false
                 rendererId: ""
 
-                Connections {
-                    target: AvAdapter
-
-                    function onCurrentRenderingDeviceIdChanged() {
-                        previewRenderer.rendererId = AvAdapter.currentRenderingDeviceId
-                    }
-                }
-
                 height: width * invAspectRatio
                 width: Math.max(callPageMainRect.width / 5, JamiTheme.minimumPreviewWidth)
                 x: callPageMainRect.width - previewRenderer.width - previewMargin
@@ -312,6 +304,7 @@ Rectangle {
                                              isGrid)
                         callOverlay.isVideoMuted = !AvAdapter.isCapturing()
                         callOverlay.sharingActive = AvAdapter.isSharing()
+                        previewRenderer.rendererId = previewId
                         previewRenderer.visible = (AvAdapter.isSharing() || AvAdapter.isCapturing()) && participantsLayer.count == 0
                     }
 
-- 
GitLab