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