From f706abe5a65bb3c6a09775411a1fd8d977ceaa87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Blin?= <sebastien.blin@savoirfairelinux.com> Date: Mon, 26 Feb 2024 15:51:57 -0500 Subject: [PATCH] CallMessageDelegate: do not show button to join current call GitLab: #963 Change-Id: If26b9413e5a94e1b9da0842b84eaf8019b08140f --- .../commoncomponents/CallMessageDelegate.qml | 21 ++++++++++++------- tests/qml/src/tst_CallMessageDelegate.qml | 19 +++++++++++++++++ 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/src/app/commoncomponents/CallMessageDelegate.qml b/src/app/commoncomponents/CallMessageDelegate.qml index 79dbb0c01..f60c1af23 100644 --- a/src/app/commoncomponents/CallMessageDelegate.qml +++ b/src/app/commoncomponents/CallMessageDelegate.qml @@ -26,8 +26,10 @@ import net.jami.Constants 1.1 SBSMessageBase { id: root + property var confId: ConfId + property var currentCallId: CurrentCall.id component JoinCallButton: MaterialButton { - visible: root.isActive + visible: root.isActive && root.currentCallId !== root.confId toolTipText: JamiStrings.joinCall color: JamiTheme.blackColor background.opacity: hovered ? 0.2 : 0.1 @@ -56,7 +58,7 @@ SBSMessageBase { enabled: root.isActive function onActiveCallsChanged() { - root.isActive = LRCInstance.indexOfActiveCall(ConfId, ActionUri, DeviceId) !== -1; + root.isActive = LRCInstance.indexOfActiveCall(root.confId, ActionUri, DeviceId) !== -1; if (root.isActive) { bubble.mask.border.color = CurrentConversation.color; bubble.mask.border.width = 1.5; @@ -65,8 +67,8 @@ SBSMessageBase { } } - property bool isActive: LRCInstance.indexOfActiveCall(ConfId, ActionUri, DeviceId) !== -1 - visible: isActive || ConfId === "" || Duration > 0 + property bool isActive: LRCInstance.indexOfActiveCall(root.confId, ActionUri, DeviceId) !== -1 + visible: isActive || root.confId === "" || Duration > 0 property var baseColor: JamiTheme.messageInBgColor @@ -113,12 +115,13 @@ SBSMessageBase { TextEdit { id: callLabel + objectName: "callLabel" topPadding: 8 bottomPadding: 8 Layout.fillWidth: true - Layout.rightMargin: root.isActive ? 0 : root.timeWidth + 16 + Layout.rightMargin: root.isActive && root.currentCallId !== root.confId ? 0 : root.timeWidth + 16 Layout.leftMargin: root.isActive ? 10 : -5 /* spacing is 10 and we want 5px with icon */ text: { @@ -139,20 +142,22 @@ SBSMessageBase { JoinCallButton { id: joinCallInAudio + objectName: "joinCallInAudio" Layout.topMargin: 4 Layout.bottomMargin: 4 text: JamiStrings.joinInAudio - onClicked: MessagesAdapter.joinCall(ActionUri, DeviceId, ConfId, true) + onClicked: MessagesAdapter.joinCall(ActionUri, DeviceId, root.confId, true) } JoinCallButton { id: joinCallInVideo + objectName: "joinCallInVideo" text: JamiStrings.joinInVideo Layout.topMargin: 4 Layout.bottomMargin: 4 - onClicked: MessagesAdapter.joinCall(ActionUri, DeviceId, ConfId) + onClicked: MessagesAdapter.joinCall(ActionUri, DeviceId, root.confId) Layout.rightMargin: 4 } } @@ -165,7 +170,7 @@ SBSMessageBase { } } Component.onCompleted: { - bubble.timestampItem.visible = !root.isActive; + bubble.timestampItem.visible = !root.isActive || root.currentCallId === root.confId; opacity = 1; } } diff --git a/tests/qml/src/tst_CallMessageDelegate.qml b/tests/qml/src/tst_CallMessageDelegate.qml index a7b022b75..e7caacda5 100644 --- a/tests/qml/src/tst_CallMessageDelegate.qml +++ b/tests/qml/src/tst_CallMessageDelegate.qml @@ -43,5 +43,24 @@ TestWrapper { compare(replyButton.visible, false) } } + + TestCase { + name: "Check button visibility for swarm call" + function test_checkOptionButtonsVisibility() { + uut.isActive = true + uut.currentCallId = "foo" + uut.confId = "foo" + var callLabel = findChild(uut, "callLabel") + var joinCallInAudio = findChild(uut, "joinCallInAudio") + var joinCallInVideo = findChild(uut, "joinCallInVideo") + compare(callLabel.visible, true) + compare(joinCallInAudio.visible, false) + compare(joinCallInVideo.visible, false) + uut.confId = "bar" + compare(callLabel.visible, true) + compare(joinCallInAudio.visible, true) + compare(joinCallInVideo.visible, true) + } + } } } -- GitLab