const { ipcRenderer } = window . electron_functions ; import mimeTypes from 'mime-types' ; import { MessageTypeAttachmentSubset } from '../../../shared/shared-types' ; import { DraftObject } from '../composer/Composer' ; const SUPPORTED_IMAGE_MIME_TYPES = Object . freeze ( [ 'image/bmp' , 'image/gif' , 'image/jpeg' , 'image/jpg' , 'image/svg+xml' , 'image/webp' , 'image/x-xbitmap' , 'image/vnd.microsoft.icon' , 'image/ico' , 'image/icon' , 'image/x-icon' , 'image/apng' , 'image/png' , 'image/x' , ] ) ; const SUPPORTED_VIDEO_MIME_TYPES = Object . freeze ( [ 'video/mp4' , 'video/ogg' , 'video/webm' , ] ) ; export function isImage ( filemime ) { return SUPPORTED_IMAGE_MIME_TYPES . includes ( filemime || '' ) ; } export function hasAttachment ( attachment ) { return attachment && attachment . file ; } export function isVideo ( filemime ) { return SUPPORTED_VIDEO_MIME_TYPES . includes ( filemime || '' ) ; } export function isAudio ( filemime ) { if ( ! filemime ) return false ; return filemime . startsWith ( 'audio/' ) ; } export function isDisplayableByFullscreenMedia ( filemime ) { return isImage ( filemime ) || isAudio ( filemime ) || isVideo ( filemime ) ; } export function isGenericAttachment ( filemime ) { return ! ( isImage ( filemime ) || isVideo ( filemime ) || isAudio ( filemime ) ) ; } export function getExtension ( { file_name , file_mime , } ) { if ( file_name && file_name . indexOf ( '.' ) >= 0 ) { const lastPeriod = file_name . lastIndexOf ( '.' ) ; const extension = file_name . slice ( lastPeriod + 1 ) ; if ( extension . length ) { return extension ; } } return mimeTypes . extension ( file_mime || '' ) || null ; } export function dragAttachmentOut ( file , dragEvent ) { dragEvent . preventDefault ( ) ; ipcRenderer . send ( 'ondragstart' , file ) ; }