From f4190ccae206e68c3e4cbd4c4611e101e94182e3 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Sun, 27 Dec 2020 21:01:51 +0000 Subject: [PATCH] Fix mini avatar uploader "working" even without permissions --- src/components/views/elements/MiniAvatarUploader.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/components/views/elements/MiniAvatarUploader.tsx b/src/components/views/elements/MiniAvatarUploader.tsx index 8517da6dfb..51b55601f7 100644 --- a/src/components/views/elements/MiniAvatarUploader.tsx +++ b/src/components/views/elements/MiniAvatarUploader.tsx @@ -15,6 +15,7 @@ limitations under the License. */ import React, {useContext, useRef, useState} from 'react'; +import {EventType} from 'matrix-js-sdk/src/@types/event'; import classNames from 'classnames'; import AccessibleButton from "./AccessibleButton"; @@ -23,6 +24,7 @@ import MatrixClientContext from "../../../contexts/MatrixClientContext"; import {useTimeout} from "../../../hooks/useTimeout"; import Analytics from "../../../Analytics"; import CountlyAnalytics from '../../../CountlyAnalytics'; +import RoomContext from "../../../contexts/RoomContext"; export const AVATAR_SIZE = 52; @@ -50,6 +52,10 @@ const MiniAvatarUploader: React.FC = ({ hasAvatar, hasAvatarLabel, noAva const label = (hasAvatar || busy) ? hasAvatarLabel : noAvatarLabel; + const {room} = useContext(RoomContext); + const canSetAvatar = room?.currentState.maySendStateEvent(EventType.RoomAvatar, cli.getUserId()); + if (!canSetAvatar) return children; + return