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

Commit

Permalink
Add reactions button to msg context menu
Browse files Browse the repository at this point in the history
  • Loading branch information
simobot committed Mar 14, 2022
1 parent 54bdf28 commit 72d0c08
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
4 changes: 4 additions & 0 deletions res/css/views/context_menus/_MessageContextMenu.scss
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,8 @@ limitations under the License.
.mx_MessageContextMenu_iconViewInRoom::before {
mask-image: url('$(res)/img/element-icons/view-in-room.svg');
}

.mx_MessageContextMenu_iconEmoji::before {
mask-image: url('$(res)/img/element-icons/room/composer/emoji.svg');
}
}
19 changes: 19 additions & 0 deletions src/components/views/context_menus/MessageContextMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import { Action } from "../../../dispatcher/actions";
import ReportEventDialog from '../dialogs/ReportEventDialog';
import ViewSource from '../../structures/ViewSource';
import { createRedactEventDialog } from '../dialogs/ConfirmRedactDialog';
import ReactionsDialog from '../dialogs/ReactionsDialog';
import ShareDialog from '../dialogs/ShareDialog';
import { RoomPermalinkCreator } from "../../../utils/permalinks/Permalinks";
import { ChevronFace, IPosition } from '../../structures/ContextMenu';
Expand Down Expand Up @@ -81,6 +82,7 @@ interface IProps extends IPosition {
relationType: string,
eventType: string
) => Relations;
reactions?: Relations;
}

interface IState {
Expand Down Expand Up @@ -169,6 +171,14 @@ export default class MessageContextMenu extends React.Component<IProps, IState>
this.closeMenu();
};

private onReactionsClick = (): void => {
Modal.createTrackedDialog('Reactions', '', ReactionsDialog, {
mxEvent: this.props.mxEvent,
reactions: this.props.reactions,
}, 'mx_Dialog_viewsource');
this.closeMenu();
};

private onRedactClick = (): void => {
const { mxEvent, onCloseDialog } = this.props;
createRedactEventDialog({
Expand Down Expand Up @@ -367,6 +377,14 @@ export default class MessageContextMenu extends React.Component<IProps, IState>
/>
);

const reactionsButton = (
<IconizedContextMenuOption
iconClassName="mx_MessageContextMenu_iconEmoji"
label={_t("Reactions")}
onClick={this.onReactionsClick}
/>
);

if (this.props.eventTileOps) {
if (this.props.eventTileOps.isWidgetHidden()) {
unhidePreviewButton = (
Expand Down Expand Up @@ -491,6 +509,7 @@ export default class MessageContextMenu extends React.Component<IProps, IState>
{ externalURLButton }
{ unhidePreviewButton }
{ viewSourceButton }
{ reactionsButton }
{ resendReactionsButton }
{ collapseReplyChain }
</IconizedContextMenuOptionList>
Expand Down
4 changes: 4 additions & 0 deletions src/components/views/messages/MessageActionBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ interface IOptionsButtonProps {
relationType: string,
eventType: string
) => Relations;
reactions: Relations;
}

const OptionsButton: React.FC<IOptionsButtonProps> = ({
Expand All @@ -67,6 +68,7 @@ const OptionsButton: React.FC<IOptionsButtonProps> = ({
permalinkCreator,
onFocusChange,
getRelationsForEvent,
reactions,
}) => {
const [menuDisplayed, button, openMenu, closeMenu] = useContextMenu();
const [onFocus, isActive, ref] = useRovingTabIndex(button);
Expand All @@ -88,6 +90,7 @@ const OptionsButton: React.FC<IOptionsButtonProps> = ({
collapseReplyChain={replyChain && replyChain.canCollapse() ? replyChain.collapse : undefined}
onFinished={closeMenu}
getRelationsForEvent={getRelationsForEvent}
reactions={reactions}
/>;
}

Expand Down Expand Up @@ -418,6 +421,7 @@ export default class MessageActionBar extends React.PureComponent<IMessageAction
onFocusChange={this.onFocusChange}
key="menu"
getRelationsForEvent={this.props.getRelationsForEvent}
reactions={this.props.reactions}
/>);
}

Expand Down

0 comments on commit 72d0c08

Please sign in to comment.