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
This commit is contained in:
parent
de4e0cfcaa
commit
007b8816df
1 changed files with 4 additions and 9 deletions
|
@ -165,11 +165,6 @@ export default class ReactionsRow extends React.PureComponent<IProps, IState> {
|
||||||
return null;
|
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]) => {
|
let items = reactions.getSortedAnnotationsByKey().map(([content, events]) => {
|
||||||
const count = events.size;
|
const count = events.size;
|
||||||
if (!count) {
|
if (!count) {
|
||||||
|
@ -188,7 +183,7 @@ export default class ReactionsRow extends React.PureComponent<IProps, IState> {
|
||||||
mxEvent={mxEvent}
|
mxEvent={mxEvent}
|
||||||
reactionEvents={events}
|
reactionEvents={events}
|
||||||
myReactionEvent={myReactionEvent}
|
myReactionEvent={myReactionEvent}
|
||||||
disabled={!canReact}
|
disabled={!this.context.canReact}
|
||||||
/>;
|
/>;
|
||||||
}).filter(item => !!item);
|
}).filter(item => !!item);
|
||||||
|
|
||||||
|
@ -197,7 +192,7 @@ export default class ReactionsRow extends React.PureComponent<IProps, IState> {
|
||||||
// Show the first MAX_ITEMS if there are MAX_ITEMS + 1 or more items.
|
// 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
|
// The "+ 1" ensure that the "show all" reveals something that takes up
|
||||||
// more space than the button itself.
|
// more space than the button itself.
|
||||||
let showAllButton;
|
let showAllButton: JSX.Element;
|
||||||
if ((items.length > MAX_ITEMS_WHEN_LIMITED + 1) && !showAll) {
|
if ((items.length > MAX_ITEMS_WHEN_LIMITED + 1) && !showAll) {
|
||||||
items = items.slice(0, MAX_ITEMS_WHEN_LIMITED);
|
items = items.slice(0, MAX_ITEMS_WHEN_LIMITED);
|
||||||
showAllButton = <AccessibleButton
|
showAllButton = <AccessibleButton
|
||||||
|
@ -209,8 +204,8 @@ export default class ReactionsRow extends React.PureComponent<IProps, IState> {
|
||||||
</AccessibleButton>;
|
</AccessibleButton>;
|
||||||
}
|
}
|
||||||
|
|
||||||
let addReactionButton;
|
let addReactionButton: JSX.Element;
|
||||||
if (room.getMyMembership() === "join" && this.context.canReact) {
|
if (this.context.canReact) {
|
||||||
addReactionButton = <ReactButton mxEvent={mxEvent} reactions={reactions} />;
|
addReactionButton = <ReactButton mxEvent={mxEvent} reactions={reactions} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue