Attachment Modal: Allow spoilers for .gif files (#4415)
This commit is contained in:
parent
3dbef9802f
commit
0ddc3bb035
@ -14,7 +14,6 @@ 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,
|
||||
@ -355,7 +354,7 @@ const AttachmentModal: FC<OwnProps & StateProps> = ({
|
||||
const handleEnableSpoilers = useLastCallback(() => {
|
||||
onAttachmentsUpdate(attachments.map((a) => ({
|
||||
...a,
|
||||
shouldSendAsSpoiler: a.mimeType !== GIF_MIME_TYPE ? true : undefined,
|
||||
shouldSendAsSpoiler: true,
|
||||
})));
|
||||
});
|
||||
|
||||
@ -424,8 +423,7 @@ const AttachmentModal: FC<OwnProps & StateProps> = ({
|
||||
|
||||
const hasAnySpoilerable = useMemo(() => {
|
||||
if (!renderingAttachments) return false;
|
||||
return renderingAttachments.some((a) => a.mimeType !== GIF_MIME_TYPE
|
||||
&& !SUPPORTED_AUDIO_CONTENT_TYPES.has(a.mimeType));
|
||||
return renderingAttachments.some((a) => !SUPPORTED_AUDIO_CONTENT_TYPES.has(a.mimeType));
|
||||
}, [renderingAttachments]);
|
||||
|
||||
if (!renderingAttachments) {
|
||||
|
||||
@ -3,7 +3,7 @@ import React, { memo, useMemo } from '../../../lib/teact/teact';
|
||||
|
||||
import type { ApiAttachment } from '../../../api/types';
|
||||
|
||||
import { GIF_MIME_TYPE, SUPPORTED_IMAGE_CONTENT_TYPES, SUPPORTED_VIDEO_CONTENT_TYPES } from '../../../config';
|
||||
import { SUPPORTED_IMAGE_CONTENT_TYPES, SUPPORTED_VIDEO_CONTENT_TYPES } from '../../../config';
|
||||
import buildClassName from '../../../util/buildClassName';
|
||||
import { formatMediaDuration } from '../../../util/dateFormat';
|
||||
import { getFileExtension } from '../../common/helpers/documentInfo';
|
||||
@ -95,9 +95,7 @@ const AttachmentModalItem: FC<OwnProps> = ({
|
||||
}, [attachment, displayType, index, onDelete]);
|
||||
|
||||
const shouldSkipGrouping = displayType === 'file' || !shouldDisplayGrouped;
|
||||
const canDisplaySpoilerButton = attachment.mimeType !== GIF_MIME_TYPE;
|
||||
const shouldDisplaySpoiler = Boolean(displayType !== 'file' && canDisplaySpoilerButton
|
||||
&& attachment.shouldSendAsSpoiler);
|
||||
const shouldDisplaySpoiler = Boolean(displayType !== 'file' && attachment.shouldSendAsSpoiler);
|
||||
const shouldRenderOverlay = displayType !== 'file';
|
||||
|
||||
const rootClassName = buildClassName(
|
||||
@ -115,16 +113,14 @@ const AttachmentModalItem: FC<OwnProps> = ({
|
||||
/>
|
||||
{shouldRenderOverlay && (
|
||||
<div className={styles.overlay}>
|
||||
{canDisplaySpoilerButton && (
|
||||
<i
|
||||
className={buildClassName(
|
||||
'icon',
|
||||
attachment.shouldSendAsSpoiler ? 'icon-spoiler-disable' : 'icon-spoiler',
|
||||
styles.actionItem,
|
||||
)}
|
||||
onClick={handleSpoilerClick}
|
||||
/>
|
||||
)}
|
||||
<i
|
||||
className={buildClassName(
|
||||
'icon',
|
||||
attachment.shouldSendAsSpoiler ? 'icon-spoiler-disable' : 'icon-spoiler',
|
||||
styles.actionItem,
|
||||
)}
|
||||
onClick={handleSpoilerClick}
|
||||
/>
|
||||
{onDelete && (
|
||||
<i
|
||||
className={buildClassName('icon', 'icon-delete', styles.actionItem)}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user