From c0ce1ede5b4a0d30ce125d869717f002983612e7 Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Wed, 6 Sep 2023 11:58:05 +1000 Subject: [PATCH] chore: add note for save as logic --- .../message/message-content/MessageContextMenu.tsx | 1 + .../message/message-item/GenericReadableMessage.tsx | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/ts/components/conversation/message/message-content/MessageContextMenu.tsx b/ts/components/conversation/message/message-content/MessageContextMenu.tsx index 7bfdac139..51de3e833 100644 --- a/ts/components/conversation/message/message-content/MessageContextMenu.tsx +++ b/ts/components/conversation/message/message-content/MessageContextMenu.tsx @@ -281,6 +281,7 @@ export const MessageContextMenu = (props: Props) => { const saveAttachment = (e: ItemParams) => { // this is quite dirty but considering that we want the context menu of the message to show on click on the attachment // and the context menu save attachment item to save the right attachment I did not find a better way for now. + // Note: If you change this, also make sure to update the `handleContextMenu()` in GenericReadableMessage.tsx const targetAttachmentIndex = isNumber(e?.props?.dataAttachmentIndex) ? e.props.dataAttachmentIndex : 0; diff --git a/ts/components/conversation/message/message-item/GenericReadableMessage.tsx b/ts/components/conversation/message/message-item/GenericReadableMessage.tsx index d9dc7e450..5eb8444e9 100644 --- a/ts/components/conversation/message/message-item/GenericReadableMessage.tsx +++ b/ts/components/conversation/message/message-item/GenericReadableMessage.tsx @@ -180,6 +180,10 @@ export const GenericReadableMessage = (props: Props) => { const handleContextMenu = useCallback( (e: React.MouseEvent) => { + // this is quite dirty but considering that we want the context menu of the message to show on click on the attachment + // and the context menu save attachment item to save the right attachment I did not find a better way for now. + + // Note: If you change this, also make sure to update the `saveAttachment()` in MessageContextMenu.tsx const enableContextMenu = !multiSelectMode && !msgProps?.isKickedFromGroup; const attachmentIndexStr = (e?.target as any)?.parentElement?.getAttribute?.( 'data-attachmentindex'