From 7c3eab91073f92f007fbfcefebf3ba342ed9dcdf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Blin?=
 <sebastien.blin@savoirfairelinux.com>
Date: Mon, 8 Jan 2024 15:39:03 -0500
Subject: [PATCH] CallMessageDelegate: remove reply/react to

Change-Id: Iddeffd4e2c161ecaf0c9bdb62ed1431d78d0eac5
GitLab: #1493
---
 src/app/commoncomponents/SBSMessageBase.qml | 21 +++++++---
 tests/qml/src/tst_CallMessageDelegate.qml   | 44 +++++++++++++++++++++
 2 files changed, 59 insertions(+), 6 deletions(-)
 create mode 100644 tests/qml/src/tst_CallMessageDelegate.qml

diff --git a/src/app/commoncomponents/SBSMessageBase.qml b/src/app/commoncomponents/SBSMessageBase.qml
index 0d19f445c..3f98da23a 100644
--- a/src/app/commoncomponents/SBSMessageBase.qml
+++ b/src/app/commoncomponents/SBSMessageBase.qml
@@ -64,6 +64,7 @@ Control {
     property real maxMsgWidth: root.width - senderMargin - 2 * hPadding - avatarBlockWidth
     property bool bigMsg
     property bool timeUnderBubble: false
+    property var type: Type
 
     // If the ListView attached properties are not available,
     // then the root delegate is likely a Loader.
@@ -263,6 +264,7 @@ Control {
 
                     PushButton {
                         id: more
+                        objectName: "more"
 
                         anchors.rightMargin: isOutgoing ? 10 : 0
                         anchors.leftMargin: !isOutgoing ? 10 : 0
@@ -273,7 +275,10 @@ Control {
                         anchors.verticalCenter: parent.verticalCenter
                         anchors.right: isOutgoing ? optionButtonItem.right : undefined
                         anchors.left: !isOutgoing ? optionButtonItem.left : undefined
-                        visible: CurrentAccount.type !== Profile.Type.SIP && Body !== "" && (bubbleArea.bubbleHovered || hovered || reply.hovered || bgHandler.hovered)
+                        visible: CurrentAccount.type !== Profile.Type.SIP
+                                 && root.type !== Interaction.Type.CALL
+                                 && Body !== ""
+                                 && (bubbleArea.bubbleHovered || hovered || reply.hovered || bgHandler.hovered)
                         source: JamiResources.more_vert_24dp_svg
                         width: optionButtonItem.width / 2
                         height: optionButtonItem.height
@@ -283,7 +288,7 @@ Control {
 
                         function bind() {
                             more.isOpen = false;
-                            visible = Qt.binding(() => CurrentAccount.type !== Profile.Type.SIP && Body !== "" && (bubbleArea.bubbleHovered || hovered || reply.hovered || bgHandler.hovered));
+                            visible = Qt.binding(() => CurrentAccount.type !== Profile.Type.SIP && root.type !== Interaction.Type.CALL && Body !== "" && (bubbleArea.bubbleHovered || hovered || reply.hovered || bgHandler.hovered));
                             imageColor = Qt.binding(() => hovered ? JamiTheme.chatViewFooterImgHoverColor : JamiTheme.chatViewFooterImgColor);
                             normalColor = Qt.binding(() => JamiTheme.primaryBackgroundColor);
                         }
@@ -299,7 +304,7 @@ Control {
                                         "isOutgoing": isOutgoing,
                                         "msgId": Id,
                                         "msgBody": Body,
-                                        "type": Type,
+                                        "type": root.type,
                                         "transferName": TransferName,
                                         "msgBubble": bubble,
                                         "listView": listView
@@ -315,6 +320,7 @@ Control {
 
                     PushButton {
                         id: reply
+                        objectName: "reply"
 
                         circled: false
                         imageColor: hovered ? JamiTheme.chatViewFooterImgHoverColor : JamiTheme.chatViewFooterImgColor
@@ -327,7 +333,10 @@ Control {
                         anchors.rightMargin: 5
                         anchors.right: isOutgoing ? more.left : undefined
                         anchors.left: !isOutgoing ? more.right : undefined
-                        visible: CurrentAccount.type !== Profile.Type.SIP && Body !== "" && (bubbleArea.bubbleHovered || hovered || more.hovered || bgHandler.hovered)
+                        visible: CurrentAccount.type !== Profile.Type.SIP
+                                 && root.type !== Interaction.Type.CALL
+                                 && Body !== ""
+                                 && (bubbleArea.bubbleHovered || hovered || more.hovered || bgHandler.hovered)
 
                         onClicked: {
                             MessagesAdapter.editId = "";
@@ -355,12 +364,12 @@ Control {
                     property bool bubbleHovered
                     property string imgSource
 
-                    width: (Type === Interaction.Type.TEXT ? root.textContentWidth : innerContent.childrenRect.width)
+                    width: (root.type === Interaction.Type.TEXT ? root.textContentWidth : innerContent.childrenRect.width)
                     height: innerContent.childrenRect.height + (visible ? root.extraHeight : 0) + (root.bigMsg ? 15 : 0)
 
                     HoverHandler {
                         target: root
-                        enabled: Type === Interaction.Type.DATA_TRANSFER
+                        enabled: root.type === Interaction.Type.DATA_TRANSFER
                         onHoveredChanged: {
                             root.hoveredLink = enabled && hovered ? bubble.imgSource : ""
                         }
diff --git a/tests/qml/src/tst_CallMessageDelegate.qml b/tests/qml/src/tst_CallMessageDelegate.qml
new file mode 100644
index 000000000..4d68c32a0
--- /dev/null
+++ b/tests/qml/src/tst_CallMessageDelegate.qml
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2024 Savoir-faire Linux Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
+
+import QtQuick
+import QtTest
+
+import net.jami.Adapters 1.1
+import net.jami.Models 1.1
+import net.jami.Constants 1.1
+import net.jami.Enums 1.1
+
+import "../../../src/app/"
+import "../../../src/app/mainview"
+import "../../../src/app/mainview/components"
+import "../../../src/app/commoncomponents"
+
+CallMessageDelegate {
+    id: uut
+    type: Interaction.Type.CALL
+
+    TestCase {
+        name: "Check basic visibility for header buttons"
+        function test_checkBasicVisibility() {
+            var moreButton = findChild(uut, "more")
+            var replyButton = findChild(uut, "reply")
+            compare(moreButton.visible, false)
+            compare(replyButton.visible, false)
+        }
+    }
+}
\ No newline at end of file
-- 
GitLab