From 3f2f839b3b44a544387b3e1f49b041e13c658e0f Mon Sep 17 00:00:00 2001 From: Germain Date: Thu, 19 May 2022 14:56:10 +0100 Subject: [PATCH] Add jump to related event context menu item (#6775) --- .../context_menus/_MessageContextMenu.scss | 4 ++++ res/img/element-icons/left-arrow.svg | 1 + .../context_menus/MessageContextMenu.tsx | 22 +++++++++++++++++++ src/i18n/strings/en_EN.json | 1 + 4 files changed, 28 insertions(+) create mode 100644 res/img/element-icons/left-arrow.svg diff --git a/res/css/views/context_menus/_MessageContextMenu.scss b/res/css/views/context_menus/_MessageContextMenu.scss index b92ce10d35..dde68e8bad 100644 --- a/res/css/views/context_menus/_MessageContextMenu.scss +++ b/res/css/views/context_menus/_MessageContextMenu.scss @@ -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'); + } } diff --git a/res/img/element-icons/left-arrow.svg b/res/img/element-icons/left-arrow.svg new file mode 100644 index 0000000000..557efbebd2 --- /dev/null +++ b/res/img/element-icons/left-arrow.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/components/views/context_menus/MessageContextMenu.tsx b/src/components/views/context_menus/MessageContextMenu.tsx index 86e9d9cc30..f77ead6f76 100644 --- a/src/components/views/context_menus/MessageContextMenu.tsx +++ b/src/components/views/context_menus/MessageContextMenu.tsx @@ -155,6 +155,15 @@ export default class MessageContextMenu extends React.Component 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({ action: Action.OpenReportEventDialog, @@ -488,6 +497,18 @@ export default class MessageContextMenu extends React.Component ); } + let jumpToRelatedEventButton: JSX.Element; + const relatedEventId = mxEvent.getWireContent()?.["m.relates_to"]?.event_id; + if (relatedEventId) { + jumpToRelatedEventButton = ( + this.onJumpToRelatedEventClick(relatedEventId)} + /> + ); + } + let reportEventButton: JSX.Element; if (mxEvent.getSender() !== me) { reportEventButton = ( @@ -608,6 +629,7 @@ export default class MessageContextMenu extends React.Component { permalinkButton } { reportEventButton } { externalURLButton } + { jumpToRelatedEventButton } { unhidePreviewButton } { viewSourceButton } { resendReactionsButton } diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index c7e7b9793d..9b82b120c3 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -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",