Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 007b881

Browse files
authored
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
1 parent de4e0cf commit 007b881

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

src/components/views/messages/ReactionsRow.tsx

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,6 @@ export default class ReactionsRow extends React.PureComponent<IProps, IState> {
165165
return null;
166166
}
167167

168-
const cli = this.context.room.client;
169-
const room = cli.getRoom(mxEvent.getRoomId());
170-
const isPeeking = room.getMyMembership() !== "join";
171-
const canReact = !isPeeking && this.context.canReact;
172-
173168
let items = reactions.getSortedAnnotationsByKey().map(([content, events]) => {
174169
const count = events.size;
175170
if (!count) {
@@ -188,7 +183,7 @@ export default class ReactionsRow extends React.PureComponent<IProps, IState> {
188183
mxEvent={mxEvent}
189184
reactionEvents={events}
190185
myReactionEvent={myReactionEvent}
191-
disabled={!canReact}
186+
disabled={!this.context.canReact}
192187
/>;
193188
}).filter(item => !!item);
194189

@@ -197,7 +192,7 @@ export default class ReactionsRow extends React.PureComponent<IProps, IState> {
197192
// Show the first MAX_ITEMS if there are MAX_ITEMS + 1 or more items.
198193
// The "+ 1" ensure that the "show all" reveals something that takes up
199194
// more space than the button itself.
200-
let showAllButton;
195+
let showAllButton: JSX.Element;
201196
if ((items.length > MAX_ITEMS_WHEN_LIMITED + 1) && !showAll) {
202197
items = items.slice(0, MAX_ITEMS_WHEN_LIMITED);
203198
showAllButton = <AccessibleButton
@@ -209,8 +204,8 @@ export default class ReactionsRow extends React.PureComponent<IProps, IState> {
209204
</AccessibleButton>;
210205
}
211206

212-
let addReactionButton;
213-
if (room.getMyMembership() === "join" && this.context.canReact) {
207+
let addReactionButton: JSX.Element;
208+
if (this.context.canReact) {
214209
addReactionButton = <ReactButton mxEvent={mxEvent} reactions={reactions} />;
215210
}
216211

0 commit comments

Comments
 (0)