From 1460220fd194c3b545cca461435859e36a18de88 Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Mon, 19 Aug 2024 17:32:48 +1000 Subject: [PATCH] fix: make attachment "save" hidden until downloaded also display mime type of file about to be downloaded before trusted contact SES-28 SES-80 --- .../message/message-content/ClickToTrustSender.tsx | 8 +++++++- .../message/message-content/MessageContextMenu.tsx | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ts/components/conversation/message/message-content/ClickToTrustSender.tsx b/ts/components/conversation/message/message-content/ClickToTrustSender.tsx index effca99a0..c8a170faa 100644 --- a/ts/components/conversation/message/message-content/ClickToTrustSender.tsx +++ b/ts/components/conversation/message/message-content/ClickToTrustSender.tsx @@ -5,6 +5,7 @@ import { AttachmentDownloads } from '../../../../session/utils'; import { updateConfirmModal } from '../../../../state/ducks/modalDialog'; import { SessionButtonColor } from '../../../basic/SessionButton'; import { SessionIcon } from '../../../icon'; +import { useMessageAttachments } from '../../../../state/selectors'; const StyledTrustSenderUI = styled.div` padding-inline: var(--margins-lg); @@ -25,6 +26,7 @@ const ClickToDownload = styled.div` `; export const ClickToTrustSender = (props: { messageId: string }) => { + const attachments = useMessageAttachments(props.messageId); const openConfirmationModal = async (e: any) => { e.stopPropagation(); e.preventDefault(); @@ -110,13 +112,17 @@ export const ClickToTrustSender = (props: { messageId: string }) => { ); }; + const firstMimeType = attachments?.[0].contentType; + return ( // eslint-disable-next-line @typescript-eslint/no-misused-promises {/** TODO - Add file type */} - {window.i18n('attachmentsClickToDownload', { file_type: '' })} + {window.i18n('attachmentsClickToDownload', { + file_type: firstMimeType || window.i18n('unknown'), + })} ); diff --git a/ts/components/conversation/message/message-content/MessageContextMenu.tsx b/ts/components/conversation/message/message-content/MessageContextMenu.tsx index 5dbf93476..e4d3200aa 100644 --- a/ts/components/conversation/message/message-content/MessageContextMenu.tsx +++ b/ts/components/conversation/message/message-content/MessageContextMenu.tsx @@ -370,8 +370,8 @@ export const MessageContextMenu = (props: Props) => { messageId={messageId} /> )} - {attachments?.length ? ( - {window.i18n('attachmentsDownload')} + {attachments?.length && attachments.every(m => !m.pending && m.path) ? ( + {window.i18n('save')} ) : null} {window.i18n('copy')} {(isSent || !isOutgoing) && {window.i18n('reply')}}