diff --git a/src/components/views/emojipicker/ReactionPicker.tsx b/src/components/views/emojipicker/ReactionPicker.tsx index b7af3310384b..9d613b319229 100644 --- a/src/components/views/emojipicker/ReactionPicker.tsx +++ b/src/components/views/emojipicker/ReactionPicker.tsx @@ -26,7 +26,6 @@ import dis from "../../../dispatcher/dispatcher"; import { Action } from '../../../dispatcher/actions'; import RoomContext from "../../../contexts/RoomContext"; import { FocusComposerPayload } from '../../../dispatcher/payloads/FocusComposerPayload'; -import { canRedact } from "../../../utils/EventUtils"; interface IProps { mxEvent: MatrixEvent; @@ -97,7 +96,7 @@ class ReactionPicker extends React.Component { const roomId = this.props.mxEvent.getRoomId(); const myReactions = this.getReactions(); if (myReactions.hasOwnProperty(reaction)) { - if (!canRedact(roomId, myReactions[reaction])) return; + if (this.props.mxEvent.isRedacted() || !this.context.canSelfRedact) return; MatrixClientPeg.get().redactEvent(roomId, myReactions[reaction].getId()); dis.dispatch({ @@ -124,10 +123,11 @@ class ReactionPicker extends React.Component { }; private isEmojiDisabled = (unicode: string): boolean => { - const reaction = this.getReactions()[unicode]; + if (!this.getReactions()[unicode]) return false; + if (this.props.mxEvent.isRedacted()) return false; + if (this.context.canSelfRedact) return false; - if (!reaction) return false; - return !canRedact(this.props.mxEvent.getRoomId(), reaction); + return true; }; render() { diff --git a/src/components/views/messages/ReactionsRow.tsx b/src/components/views/messages/ReactionsRow.tsx index 2ead0ecbbd5b..852a36d1fa23 100644 --- a/src/components/views/messages/ReactionsRow.tsx +++ b/src/components/views/messages/ReactionsRow.tsx @@ -160,6 +160,7 @@ export default class ReactionsRow extends React.PureComponent { render() { const { mxEvent, reactions } = this.props; const { myReactions, showAll } = this.state; + console.log(`LOG rendering ${isContentActionable(mxEvent)}; ${reactions}`); if (!reactions || !isContentActionable(mxEvent)) { return null; @@ -183,7 +184,10 @@ export default class ReactionsRow extends React.PureComponent { mxEvent={mxEvent} reactionEvents={events} myReactionEvent={myReactionEvent} - disabled={!this.context.canReact} + disabled={( + !this.context.canReact || + (myReactionEvent && !myReactionEvent.isRedacted() && this.context.canSelfRedact) + )} />; }).filter(item => !!item); diff --git a/src/components/views/messages/ReactionsRowButton.tsx b/src/components/views/messages/ReactionsRowButton.tsx index 78dd7e6b5b03..2d78f2b673a8 100644 --- a/src/components/views/messages/ReactionsRowButton.tsx +++ b/src/components/views/messages/ReactionsRowButton.tsx @@ -24,7 +24,6 @@ import dis from "../../../dispatcher/dispatcher"; import ReactionsRowButtonTooltip from "./ReactionsRowButtonTooltip"; import AccessibleButton from "../elements/AccessibleButton"; import MatrixClientContext from "../../../contexts/MatrixClientContext"; -import { canRedact } from "../../../utils/EventUtils"; interface IProps { // The event we're displaying reactions for @@ -59,7 +58,6 @@ export default class ReactionsRowButton extends React.PureComponent diff --git a/src/utils/EventUtils.ts b/src/utils/EventUtils.ts index 6758e292d8c2..7bd4ed844718 100644 --- a/src/utils/EventUtils.ts +++ b/src/utils/EventUtils.ts @@ -292,9 +292,3 @@ export function canForward(event: MatrixEvent): boolean { export function hasThreadSummary(event: MatrixEvent): boolean { return event.isThreadRoot && event.getThread()?.length && !!event.getThread().replyToEvent; } - -export function canRedact(roomId: string, mxEvent: MatrixEvent): boolean { - const client = MatrixClientPeg.get(); - const room = client.getRoom(roomId); - return room.currentState.maySendRedactionForEvent(mxEvent, client.getUserId()); -}