diff --git a/ts/types/Attachment.ts b/ts/types/Attachment.ts index 1e3d14e65..4f384d1c3 100644 --- a/ts/types/Attachment.ts +++ b/ts/types/Attachment.ts @@ -1,3 +1,6 @@ +import is from '@sindresorhus/is'; + +import * as GoogleChrome from '../GoogleChrome'; import { MIMEType } from './MIME'; @@ -16,4 +19,16 @@ export interface Attachment { // key?: ArrayBuffer; // digest?: ArrayBuffer; // flags?: number; -} +}; + +export const isVisualMedia = (attachment: Attachment): boolean => { + const { contentType } = attachment; + + if (is.undefined(contentType)) { + return false; + } + + const isSupportedImageType = GoogleChrome.isImageTypeSupported(contentType); + const isSupportedVideoType = GoogleChrome.isVideoTypeSupported(contentType); + return isSupportedImageType || isSupportedVideoType; +};