Fix mixing unsupported/supported media warning

This commit is contained in:
Jamie Kyle 2024-01-04 12:18:44 -08:00 committed by GitHub
parent 66f97b1c25
commit cba5b67f05
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -11,10 +11,12 @@ import type {
AddLinkPreviewActionType, AddLinkPreviewActionType,
RemoveLinkPreviewActionType, RemoveLinkPreviewActionType,
} from './linkPreviews'; } from './linkPreviews';
import type { import {
AttachmentType, type AttachmentType,
AttachmentDraftType, type AttachmentDraftType,
InMemoryAttachmentDraftType, type InMemoryAttachmentDraftType,
isVideoAttachment,
isImageAttachment,
} from '../../types/Attachment'; } from '../../types/Attachment';
import type { BoundActionCreatorsMapObject } from '../../hooks/useBoundActions'; import type { BoundActionCreatorsMapObject } from '../../hooks/useBoundActions';
import type { DraftBodyRanges } from '../../types/BodyRange'; import type { DraftBodyRanges } from '../../types/BodyRange';
@ -60,7 +62,7 @@ import { getRecipientsByConversation } from '../../util/getRecipientsByConversat
import { processAttachment } from '../../util/processAttachment'; import { processAttachment } from '../../util/processAttachment';
import { hasDraftAttachments } from '../../util/hasDraftAttachments'; import { hasDraftAttachments } from '../../util/hasDraftAttachments';
import { isFileDangerous } from '../../util/isFileDangerous'; import { isFileDangerous } from '../../util/isFileDangerous';
import { isImage, isVideo, stringToMIMEType } from '../../types/MIME'; import { stringToMIMEType } from '../../types/MIME';
import { isNotNil } from '../../util/isNotNil'; import { isNotNil } from '../../util/isNotNil';
import { replaceIndex } from '../../util/replaceIndex'; import { replaceIndex } from '../../util/replaceIndex';
import { resolveAttachmentDraftData } from '../../util/resolveAttachmentDraftData'; import { resolveAttachmentDraftData } from '../../util/resolveAttachmentDraftData';
@ -91,6 +93,10 @@ import { sendEditedMessage as doSendEditedMessage } from '../../util/sendEditedM
import { maybeBlockSendForFormattingModal } from '../../util/maybeBlockSendForFormattingModal'; import { maybeBlockSendForFormattingModal } from '../../util/maybeBlockSendForFormattingModal';
import { maybeBlockSendForEditWarningModal } from '../../util/maybeBlockSendForEditWarningModal'; import { maybeBlockSendForEditWarningModal } from '../../util/maybeBlockSendForEditWarningModal';
import { Sound, SoundType } from '../../util/Sound'; import { Sound, SoundType } from '../../util/Sound';
import {
isImageTypeSupported,
isVideoTypeSupported,
} from '../../util/GoogleChrome';
// State // State
// eslint-disable-next-line local-rules/type-alias-readonlydeep // eslint-disable-next-line local-rules/type-alias-readonlydeep
@ -1147,9 +1153,7 @@ function preProcessAttachment(
const haveNonImageOrVideo = draftAttachments.some( const haveNonImageOrVideo = draftAttachments.some(
(attachment: AttachmentDraftType) => { (attachment: AttachmentDraftType) => {
return ( return !isImageAttachment(attachment) && !isVideoAttachment(attachment);
!isImage(attachment.contentType) && !isVideo(attachment.contentType)
);
} }
); );
// You can't add another attachment if you already have a non-image staged // You can't add another attachment if you already have a non-image staged
@ -1158,7 +1162,8 @@ function preProcessAttachment(
} }
const fileType = stringToMIMEType(file.type); const fileType = stringToMIMEType(file.type);
const imageOrVideo = isImage(fileType) || isVideo(fileType); const imageOrVideo =
isImageTypeSupported(fileType) || isVideoTypeSupported(fileType);
// You can't add a non-image attachment if you already have attachments staged // You can't add a non-image attachment if you already have attachments staged
if (!imageOrVideo && draftAttachments.length > 0) { if (!imageOrVideo && draftAttachments.length > 0) {