From 202ff53c4137ba6fa02acc7d78e99534d6f05cc8 Mon Sep 17 00:00:00 2001 From: Ajay Bura Date: Wed, 26 Jan 2022 17:16:40 +0530 Subject: [PATCH] Hide reaction picker for user without permission Signed-off-by: Ajay Bura --- src/app/molecules/message/Message.jsx | 38 ++++++++++++++++----------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/src/app/molecules/message/Message.jsx b/src/app/molecules/message/Message.jsx index 6170b9f..8d3b61f 100644 --- a/src/app/molecules/message/Message.jsx +++ b/src/app/molecules/message/Message.jsx @@ -354,11 +354,12 @@ MessageReaction.propTypes = { }; function MessageReactionGroup({ roomTimeline, mEvent }) { - const { roomId, reactionTimeline } = roomTimeline; + const { roomId, room, reactionTimeline } = roomTimeline; const eventId = mEvent.getId(); const mx = initMatrix.matrixClient; const reactions = {}; - const shortcodeToEmoji = getShortcodeToCustomEmoji(roomTimeline.room); + const shortcodeToEmoji = getShortcodeToCustomEmoji(room); + const canSendReaction = room.currentState.maySendEvent('m.reaction', mx.getUserId()); const eventReactions = reactionTimeline.get(eventId); const addReaction = (key, count, senderId, isActive) => { @@ -416,14 +417,16 @@ function MessageReactionGroup({ roomTimeline, mEvent }) { /> )) } - { - pickEmoji(e, roomId, eventId, roomTimeline); - }} - src={EmojiAddIC} - size="extra-small" - tooltip="Add reaction" - /> + {canSendReaction && ( + { + pickEmoji(e, roomId, eventId, roomTimeline); + }} + src={EmojiAddIC} + size="extra-small" + tooltip="Add reaction" + /> + )} ); } @@ -452,15 +455,18 @@ const MessageOptions = React.memo(({ const myPowerlevel = room.getMember(mx.getUserId())?.powerLevel; const canIRedact = room.currentState.hasSufficientPowerLevelFor('redact', myPowerlevel); + const canSendReaction = room.currentState.maySendEvent('m.reaction', mx.getUserId()); return (
- pickEmoji(e, roomId, eventId, roomTimeline)} - src={EmojiAddIC} - size="extra-small" - tooltip="Add reaction" - /> + {canSendReaction && ( + pickEmoji(e, roomId, eventId, roomTimeline)} + src={EmojiAddIC} + size="extra-small" + tooltip="Add reaction" + /> + )} reply()} src={ReplyArrowIC}