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

Commit 274c686

Browse files
committed
Add reactions button to msg context menu
1 parent 63fd395 commit 274c686

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

res/css/views/context_menus/_MessageContextMenu.scss

+4
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,8 @@ limitations under the License.
9393
.mx_MessageContextMenu_iconViewInRoom::before {
9494
mask-image: url('$(res)/img/element-icons/view-in-room.svg');
9595
}
96+
97+
.mx_MessageContextMenu_iconEmoji::before {
98+
mask-image: url('$(res)/img/element-icons/room/composer/emoji.svg');
99+
}
96100
}

src/components/views/context_menus/MessageContextMenu.tsx

+19
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import { Action } from "../../../dispatcher/actions";
3939
import ReportEventDialog from '../dialogs/ReportEventDialog';
4040
import ViewSource from '../../structures/ViewSource';
4141
import { createRedactEventDialog } from '../dialogs/ConfirmRedactDialog';
42+
import ReactionsDialog from '../dialogs/ReactionsDialog';
4243
import ShareDialog from '../dialogs/ShareDialog';
4344
import { RoomPermalinkCreator } from "../../../utils/permalinks/Permalinks";
4445
import { ChevronFace, IPosition } from '../../structures/ContextMenu';
@@ -81,6 +82,7 @@ interface IProps extends IPosition {
8182
relationType: string,
8283
eventType: string
8384
) => Relations;
85+
reactions?: Relations;
8486
}
8587

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

174+
private onReactionsClick = (): void => {
175+
Modal.createTrackedDialog('Reactions', '', ReactionsDialog, {
176+
mxEvent: this.props.mxEvent,
177+
reactions: this.props.reactions,
178+
}, 'mx_Dialog_viewsource');
179+
this.closeMenu();
180+
};
181+
172182
private onRedactClick = (): void => {
173183
const { mxEvent, onCloseDialog } = this.props;
174184
createRedactEventDialog({
@@ -367,6 +377,14 @@ export default class MessageContextMenu extends React.Component<IProps, IState>
367377
/>
368378
);
369379

380+
const reactionsButton = (
381+
<IconizedContextMenuOption
382+
iconClassName="mx_MessageContextMenu_iconEmoji"
383+
label={_t("Reactions")}
384+
onClick={this.onReactionsClick}
385+
/>
386+
);
387+
370388
if (this.props.eventTileOps) {
371389
if (this.props.eventTileOps.isWidgetHidden()) {
372390
unhidePreviewButton = (
@@ -491,6 +509,7 @@ export default class MessageContextMenu extends React.Component<IProps, IState>
491509
{ externalURLButton }
492510
{ unhidePreviewButton }
493511
{ viewSourceButton }
512+
{ reactionsButton }
494513
{ resendReactionsButton }
495514
{ collapseReplyChain }
496515
</IconizedContextMenuOptionList>

src/components/views/messages/MessageActionBar.tsx

+4
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ interface IOptionsButtonProps {
5858
relationType: string,
5959
eventType: string
6060
) => Relations;
61+
reactions: Relations;
6162
}
6263

6364
const OptionsButton: React.FC<IOptionsButtonProps> = ({
@@ -67,6 +68,7 @@ const OptionsButton: React.FC<IOptionsButtonProps> = ({
6768
permalinkCreator,
6869
onFocusChange,
6970
getRelationsForEvent,
71+
reactions,
7072
}) => {
7173
const [menuDisplayed, button, openMenu, closeMenu] = useContextMenu();
7274
const [onFocus, isActive, ref] = useRovingTabIndex(button);
@@ -88,6 +90,7 @@ const OptionsButton: React.FC<IOptionsButtonProps> = ({
8890
collapseReplyChain={replyChain && replyChain.canCollapse() ? replyChain.collapse : undefined}
8991
onFinished={closeMenu}
9092
getRelationsForEvent={getRelationsForEvent}
93+
reactions={reactions}
9194
/>;
9295
}
9396

@@ -418,6 +421,7 @@ export default class MessageActionBar extends React.PureComponent<IMessageAction
418421
onFocusChange={this.onFocusChange}
419422
key="menu"
420423
getRelationsForEvent={this.props.getRelationsForEvent}
424+
reactions={this.props.reactions}
421425
/>);
422426
}
423427

0 commit comments

Comments
 (0)