diff --git a/src/components/middle/composer/AttachmentModal.tsx b/src/components/middle/composer/AttachmentModal.tsx index 656c4db27..4b8cb2eca 100644 --- a/src/components/middle/composer/AttachmentModal.tsx +++ b/src/components/middle/composer/AttachmentModal.tsx @@ -13,6 +13,7 @@ import type { Signal } from '../../../util/signals'; import { BASE_EMOJI_KEYWORD_LANG, EDITABLE_INPUT_MODAL_ID, + GIF_MIME_TYPE, SUPPORTED_AUDIO_CONTENT_TYPES, SUPPORTED_IMAGE_CONTENT_TYPES, SUPPORTED_VIDEO_CONTENT_TYPES, @@ -328,7 +329,10 @@ const AttachmentModal: FC = ({ }, [attachments, onAttachmentsUpdate]); const handleEnableSpoilers = useCallback(() => { - onAttachmentsUpdate(attachments.map((a) => ({ ...a, shouldSendAsSpoiler: true }))); + onAttachmentsUpdate(attachments.map((a) => ({ + ...a, + shouldSendAsSpoiler: a.mimeType !== GIF_MIME_TYPE ? true : undefined, + }))); }, [attachments, onAttachmentsUpdate]); const handleDisableSpoilers = useCallback(() => { @@ -381,6 +385,12 @@ const AttachmentModal: FC = ({ return [everyPhoto, everyVideo, everyAudio]; }, [renderingAttachments, isQuickGallery]); + const hasAnySpoilerable = useMemo(() => { + if (!renderingAttachments) return false; + return renderingAttachments.some((a) => a.mimeType !== GIF_MIME_TYPE + && !SUPPORTED_AUDIO_CONTENT_TYPES.has(a.mimeType)); + }, [renderingAttachments]); + if (!renderingAttachments) { return undefined; } @@ -430,7 +440,7 @@ const AttachmentModal: FC = ({ )) } - {isSendingCompressed && ( + {isSendingCompressed && hasAnySpoilerable && ( hasSpoiler ? ( {lang('Attachment.DisableSpoiler')} diff --git a/src/components/middle/composer/AttachmentModalItem.tsx b/src/components/middle/composer/AttachmentModalItem.tsx index 7cc25c5f7..aac036f68 100644 --- a/src/components/middle/composer/AttachmentModalItem.tsx +++ b/src/components/middle/composer/AttachmentModalItem.tsx @@ -3,7 +3,7 @@ import React, { memo, useCallback, useMemo } from '../../../lib/teact/teact'; import type { FC } from '../../../lib/teact/teact'; import type { ApiAttachment } from '../../../api/types'; -import { SUPPORTED_IMAGE_CONTENT_TYPES, SUPPORTED_VIDEO_CONTENT_TYPES } from '../../../config'; +import { GIF_MIME_TYPE, SUPPORTED_IMAGE_CONTENT_TYPES, SUPPORTED_VIDEO_CONTENT_TYPES } from '../../../config'; import { getFileExtension } from '../../common/helpers/documentInfo'; import buildClassName from '../../../util/buildClassName'; import { formatMediaDuration } from '../../../util/dateFormat'; @@ -93,7 +93,9 @@ const AttachmentModalItem: FC = ({ }, [attachment, displayType, index, onDelete]); const shouldSkipGrouping = displayType === 'file' || !shouldDisplayGrouped; - const shouldDisplaySpoiler = Boolean(displayType !== 'file' && attachment.shouldSendAsSpoiler); + const canDisplaySpoilerButton = attachment.mimeType !== GIF_MIME_TYPE; + const shouldDisplaySpoiler = Boolean(displayType !== 'file' && canDisplaySpoilerButton + && attachment.shouldSendAsSpoiler); const shouldRenderOverlay = displayType !== 'file'; const rootClassName = buildClassName( @@ -111,13 +113,15 @@ const AttachmentModalItem: FC = ({ /> {shouldRenderOverlay && (
- + {canDisplaySpoilerButton && ( + + )} {onDelete && ( onDelete(index)} /> )} diff --git a/src/global/actions/api/messages.ts b/src/global/actions/api/messages.ts index e175858cd..0eb71f7b2 100644 --- a/src/global/actions/api/messages.ts +++ b/src/global/actions/api/messages.ts @@ -22,6 +22,7 @@ import { import { LoadMoreDirection } from '../../../types'; import { + GIF_MIME_TYPE, MAX_MEDIA_FILES_FOR_ALBUM, MESSAGE_LIST_SLICE, RE_TELEGRAM_LINK, @@ -1537,6 +1538,7 @@ function getAttachmentType(attachment: ApiAttachment) { shouldSendAsFile, mimeType, } = attachment; if (shouldSendAsFile) return 'file'; + if (mimeType === GIF_MIME_TYPE) return 'gif'; if (SUPPORTED_IMAGE_CONTENT_TYPES.has(mimeType) || SUPPORTED_VIDEO_CONTENT_TYPES.has(mimeType)) return 'media'; if (SUPPORTED_AUDIO_CONTENT_TYPES.has(mimeType)) return 'audio'; if (attachment.voice) return 'voice';