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

Commit

Permalink
Add jump to related event context menu item (#6775)
Browse files Browse the repository at this point in the history
  • Loading branch information
Germain authored May 19, 2022
1 parent 82169ab commit 3f2f839
Show file tree
Hide file tree
Showing 4 changed files with 28 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 @@ -109,4 +109,8 @@ limitations under the License.
.mx_MessageContextMenu_iconViewInRoom::before {
mask-image: url('$(res)/img/element-icons/view-in-room.svg');
}

.mx_MessageContextMenu_jumpToEvent::before {
mask-image: url('$(res)/img/element-icons/left-arrow.svg');
}
}
1 change: 1 addition & 0 deletions res/img/element-icons/left-arrow.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions src/components/views/context_menus/MessageContextMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,15 @@ export default class MessageContextMenu extends React.Component<IProps, IState>
this.closeMenu();
};

private onJumpToRelatedEventClick = (relatedEventId: string): void => {
dis.dispatch({
action: "view_room",
room_id: this.props.mxEvent.getRoomId(),
event_id: relatedEventId,
highlighted: true,
});
};

private onReportEventClick = (): void => {
dis.dispatch<OpenReportEventDialogPayload>({
action: Action.OpenReportEventDialog,
Expand Down Expand Up @@ -488,6 +497,18 @@ export default class MessageContextMenu extends React.Component<IProps, IState>
);
}

let jumpToRelatedEventButton: JSX.Element;
const relatedEventId = mxEvent.getWireContent()?.["m.relates_to"]?.event_id;
if (relatedEventId) {
jumpToRelatedEventButton = (
<IconizedContextMenuOption
iconClassName="mx_MessageContextMenu_jumpToEvent"
label={_t("View related event")}
onClick={() => this.onJumpToRelatedEventClick(relatedEventId)}
/>
);
}

let reportEventButton: JSX.Element;
if (mxEvent.getSender() !== me) {
reportEventButton = (
Expand Down Expand Up @@ -608,6 +629,7 @@ export default class MessageContextMenu extends React.Component<IProps, IState>
{ permalinkButton }
{ reportEventButton }
{ externalURLButton }
{ jumpToRelatedEventButton }
{ unhidePreviewButton }
{ viewSourceButton }
{ resendReactionsButton }
Expand Down
1 change: 1 addition & 0 deletions src/i18n/strings/en_EN.json
Original file line number Diff line number Diff line change
Expand Up @@ -2922,6 +2922,7 @@
"Show preview": "Show preview",
"Source URL": "Source URL",
"Collapse reply thread": "Collapse reply thread",
"View related event": "View related event",
"Report": "Report",
"Copy link": "Copy link",
"Forget": "Forget",
Expand Down

0 comments on commit 3f2f839

Please sign in to comment.