From 007b8816df747fabd0065878028037f36d6e4fdb Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 17 May 2022 14:17:27 +0100 Subject: [PATCH] Tweak ReactionsRow to make saner use of its RoomContext (#8623) * Tweak ReactionsRow to make saner use of its RoomContext * `this.context.canReact` already asserts membership=join --- src/components/views/messages/ReactionsRow.tsx | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/components/views/messages/ReactionsRow.tsx b/src/components/views/messages/ReactionsRow.tsx index 0c06474635..2ead0ecbbd 100644 --- a/src/components/views/messages/ReactionsRow.tsx +++ b/src/components/views/messages/ReactionsRow.tsx @@ -165,11 +165,6 @@ export default class ReactionsRow extends React.PureComponent { return null; } - const cli = this.context.room.client; - const room = cli.getRoom(mxEvent.getRoomId()); - const isPeeking = room.getMyMembership() !== "join"; - const canReact = !isPeeking && this.context.canReact; - let items = reactions.getSortedAnnotationsByKey().map(([content, events]) => { const count = events.size; if (!count) { @@ -188,7 +183,7 @@ export default class ReactionsRow extends React.PureComponent { mxEvent={mxEvent} reactionEvents={events} myReactionEvent={myReactionEvent} - disabled={!canReact} + disabled={!this.context.canReact} />; }).filter(item => !!item); @@ -197,7 +192,7 @@ export default class ReactionsRow extends React.PureComponent { // Show the first MAX_ITEMS if there are MAX_ITEMS + 1 or more items. // The "+ 1" ensure that the "show all" reveals something that takes up // more space than the button itself. - let showAllButton; + let showAllButton: JSX.Element; if ((items.length > MAX_ITEMS_WHEN_LIMITED + 1) && !showAll) { items = items.slice(0, MAX_ITEMS_WHEN_LIMITED); showAllButton = { ; } - let addReactionButton; - if (room.getMyMembership() === "join" && this.context.canReact) { + let addReactionButton: JSX.Element; + if (this.context.canReact) { addReactionButton = ; }