From 920bb44a3fad6dddfc505481864889204670fce4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Blin?=
 <sebastien.blin@savoirfairelinux.com>
Date: Thu, 12 May 2022 04:35:36 -0400
Subject: [PATCH] swarmdetailspanel: only change photo if enough permissions

Change-Id: I293ff9e3fbca577c660fc2c204ed75568a176bb7
---
 src/commoncomponents/PhotoboothView.qml       | 5 +++--
 src/mainview/components/SwarmDetailsPanel.qml | 1 +
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/commoncomponents/PhotoboothView.qml b/src/commoncomponents/PhotoboothView.qml
index 97b98d4bb..f31b84a2c 100644
--- a/src/commoncomponents/PhotoboothView.qml
+++ b/src/commoncomponents/PhotoboothView.qml
@@ -32,6 +32,7 @@ Item {
 
     property alias imageId: avatar.imageId
     property bool newConversation: false
+    property bool editable: true
     property real avatarSize
     property real buttonSize: avatarSize
     property bool darkTheme: false
@@ -139,7 +140,7 @@ Item {
 
             HoverHandler {
                 target: parent
-                enabled: parent.visible
+                enabled: parent.visible && editable
                 onHoveredChanged: {
                     overlayHighlighted.visible = hovered
                 }
@@ -147,7 +148,7 @@ Item {
 
             TapHandler {
                 target: parent
-                enabled: parent.visible
+                enabled: parent.visible && editable
                 onTapped: {
                     imageLayer.visible = false
                     buttonsRowLayout.visible = true
diff --git a/src/mainview/components/SwarmDetailsPanel.qml b/src/mainview/components/SwarmDetailsPanel.qml
index 7ed3fbd6a..47c2f98c5 100644
--- a/src/mainview/components/SwarmDetailsPanel.qml
+++ b/src/mainview/components/SwarmDetailsPanel.qml
@@ -48,6 +48,7 @@ Rectangle {
             PhotoboothView {
                 id: currentAccountAvatar
                 darkTheme: UtilsAdapter.luma(root.color)
+                editable: UtilsAdapter.getParticipantRole(CurrentAccount.id, CurrentConversation.id, CurrentAccount.uri) === Member.Role.ADMIN
 
                 Layout.alignment: Qt.AlignHCenter
 
-- 
GitLab