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

Commit

Permalink
Create rendering context enum for MessageActionBar
Browse files Browse the repository at this point in the history
  • Loading branch information
Germain Souquet committed Sep 28, 2021
1 parent 160bf8e commit c116583
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
11 changes: 8 additions & 3 deletions src/components/views/messages/MessageActionBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@ const ReactButton: React.FC<IReactButtonProps> = ({ mxEvent, reactions, onFocusC
</React.Fragment>;
};

export enum ActionBarRenderingContext {
Room,
Thread
}

interface IMessageActionBarProps {
mxEvent: MatrixEvent;
reactions?: Relations;
Expand All @@ -137,7 +142,7 @@ interface IMessageActionBarProps {
permalinkCreator?: RoomPermalinkCreator;
onFocusChange?: (menuDisplayed: boolean) => void;
toggleThreadExpanded: () => void;
isInThreadTimeline?: boolean;
renderingContext?: ActionBarRenderingContext;
isQuoteExpanded?: boolean;
}

Expand All @@ -146,7 +151,7 @@ export default class MessageActionBar extends React.PureComponent<IMessageAction
public static contextType = RoomContext;

public static defaultProps = {
isInThreadTimeline: false,
renderingContext: ActionBarRenderingContext.Room,
};

public componentDidMount(): void {
Expand Down Expand Up @@ -293,7 +298,7 @@ export default class MessageActionBar extends React.PureComponent<IMessageAction
// Like the resend button, the react and reply buttons need to appear before the edit.
// The only catch is we do the reply button first so that we can make sure the react
// button is the very first button without having to do length checks for `splice()`.
if (this.context.canReply && !this.props.isInThreadTimeline) {
if (this.context.canReply && this.props.renderingContext === ActionBarRenderingContext.Room) {
toolbarOpts.splice(0, 0, <>
<RovingAccessibleTooltipButton
className="mx_MessageActionBar_maskButton mx_MessageActionBar_replyButton"
Expand Down
9 changes: 6 additions & 3 deletions src/components/views/rooms/EventTile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ import SenderProfile from '../messages/SenderProfile';
import MessageTimestamp from '../messages/MessageTimestamp';
import TooltipButton from '../elements/TooltipButton';
import ReadReceiptMarker from "./ReadReceiptMarker";
import MessageActionBar from "../messages/MessageActionBar";
import MessageActionBar, { ActionBarRenderingContext } from "../messages/MessageActionBar";
import ReactionsRow from '../messages/ReactionsRow';
import { getEventDisplayInfo } from '../../../utils/EventUtils';
import { RightPanelPhases } from "../../../stores/RightPanelStorePhases";
Expand Down Expand Up @@ -1056,15 +1056,18 @@ export default class EventTile extends React.Component<IProps, IState> {
}
}

const isInThreadTimeline = this.props.tileShape === TileShape.Thread;
const renderingContext = this.props.tileShape === TileShape.Thread
? ActionBarRenderingContext.Thread
: ActionBarRenderingContext.Room;
const actionBar = !isEditing ? <MessageActionBar
mxEvent={this.props.mxEvent}
reactions={this.state.reactions}
permalinkCreator={this.props.permalinkCreator}
getTile={this.getTile}
getReplyThread={this.getReplyThread}
onFocusChange={this.onActionBarFocusChange}
isInThreadTimeline={isInThreadTimeline}
renderingContext={renderingContext}
isQuoteExpanded={isQuoteExpanded}
toggleThreadExpanded={() => this.setQuoteExpanded(!isQuoteExpanded)}
/> : undefined;

Expand Down

0 comments on commit c116583

Please sign in to comment.