@@ -38,7 +38,7 @@ import { CometChatEditPreview } from "../BaseComponents/CometChatEditPreview/Com
3838import { CometChatActionSheet } from "../BaseComponents/CometChatActionSheet/CometChatActionSheet" ;
3939import { CometChatEmojiKeyboard } from "../BaseComponents/CometChatEmojiKeyboard/CometChatEmojiKeyboard" ;
4040import { ComposerId } from '../../utils/MessagesDataSource' ;
41- import { decodeHTML , getThemeVariable , isMobileDevice , isSafari , processFileForAudio , sanitizeHtmlStringToFragment } from '../../utils/util' ;
41+ import { decodeHTML , getThemeVariable , isMobileDevice , isSafari , processFileForAudio , sanitizeHtmlStringToFragment , shouldShowCustomMimeTypes } from '../../utils/util' ;
4242import { CometChatMessageEvents } from '../../events/CometChatMessageEvents' ;
4343import { CometChatUIEvents } from '../../events/CometChatUIEvents' ;
4444import { CometChatSoundManager } from "../../resources/CometChatSoundManager/CometChatSoundManager" ;
@@ -1255,7 +1255,8 @@ try {
12551255 }
12561256
12571257 const file = mediaFilePickerElement . files [ 0 ] ;
1258- const expectedFileType = mediaFilePickerElement . accept . slice ( 0 , - 2 ) ;
1258+ const acceptAttr = mediaFilePickerElement . accept ;
1259+ let expectedFileType = ! acceptAttr || acceptAttr === "*/*" ? "file" : acceptAttr . split ( "/" ) [ 0 ]
12591260 const actualFileType = expectedFileType === "file" ? "file" : file . type . split ( '/' ) [ 0 ] ;
12601261 if ( expectedFileType !== "file" && expectedFileType !== actualFileType ) {
12611262 dispatch ( { type : "setShowValidationError" , showValidationError : true } ) ;
@@ -1711,8 +1712,20 @@ return hideAttachmentButton || (hideAudioAttachmentOption && hideVideoAttachment
17111712 if ( typeof actionOnClick === "function" ) {
17121713 actionOnClick ( ) ;
17131714 } else {
1715+ let acceptMap : Record < string , string > = {
1716+ [ CometChatUIKitConstants . MessageTypes . image ] : "image/*" ,
1717+ [ CometChatUIKitConstants . MessageTypes . video ] : "video/*" ,
1718+ [ CometChatUIKitConstants . MessageTypes . audio ] : "audio/*" ,
1719+ [ CometChatUIKitConstants . MessageTypes . file ] : "*/*"
1720+ } ;
1721+ if ( shouldShowCustomMimeTypes ( ) ) {
1722+ acceptMap [ CometChatUIKitConstants . MessageTypes . image ] = CometChatUIKitConstants . mimeTypes . image ;
1723+ acceptMap [ CometChatUIKitConstants . MessageTypes . video ] = CometChatUIKitConstants . mimeTypes . video ;
1724+ acceptMap [ CometChatUIKitConstants . MessageTypes . audio ] = CometChatUIKitConstants . mimeTypes . audio ;
1725+ }
1726+ const acceptValue = acceptMap [ action . id ] ?? "*/*" ;
17141727 // Open the correct file picker
1715- mediaFilePickerRef . current ! . accept = ` ${ action . id } /*` ;
1728+ mediaFilePickerRef . current ! . accept = acceptValue ;
17161729 mediaFilePickerRef . current ! . click ( ) ;
17171730 }
17181731 dispatch ( { type : "setContentToDisplay" , contentToDisplay : "none" } ) ;
0 commit comments