chore: add note for save as logic

fix-attachment-right-click-save-as
Audric Ackermann 9 months ago
parent 9199c7b529
commit 8fbda5db44

@ -279,12 +279,14 @@ export const MessageContextMenu = (props: Props) => {
};
const saveAttachment = (e: ItemParams) => {
e.event.stopPropagation();
// 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;
e.event.stopPropagation();
if (!attachments?.length || !convoId || !sender) {
return;
}
@ -292,6 +294,7 @@ export const MessageContextMenu = (props: Props) => {
if (targetAttachmentIndex > attachments.length) {
return;
}
const messageTimestamp = timestamp || serverTimestamp || 0;
void saveAttachmentToDisk({
attachment: attachments[targetAttachmentIndex],

@ -180,6 +180,10 @@ export const GenericReadableMessage = (props: Props) => {
const handleContextMenu = useCallback(
(e: React.MouseEvent<HTMLElement>) => {
// 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'

Loading…
Cancel
Save