Bugfix/prevent upsert when images are uploaded (#3102)

prevent upsert when images are uploaded
This commit is contained in:
Henry Heng 2024-08-28 19:06:04 +01:00 committed by GitHub
parent 690d04309b
commit 61e721fee7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 17 additions and 13 deletions

View File

@ -264,7 +264,10 @@ export const ChatMessage = ({ open, chatflowid, isAgentCanvas, isDialog, preview
}
const reader = new FileReader()
const { name } = file
// Only add files
if (!imageUploadAllowedTypes.includes(file.type)) {
uploadedFiles.push(file)
}
files.push(
new Promise((resolve) => {
reader.onload = (evt) => {
@ -340,7 +343,10 @@ export const ChatMessage = ({ open, chatflowid, isAgentCanvas, isDialog, preview
if (isFileAllowedForUpload(file) === false) {
return
}
// Only add files
if (!imageUploadAllowedTypes.includes(file.type)) {
uploadedFiles.push(file)
}
const reader = new FileReader()
const { name } = file
files.push(
@ -1197,14 +1203,11 @@ export const ChatMessage = ({ open, chatflowid, isAgentCanvas, isDialog, preview
onDrop={handleDrop}
/>
)}
{isDragActive &&
(getAllowChatFlowUploads.data?.isImageUploadAllowed || getAllowChatFlowUploads.data?.isFileAllowedForUpload) && (
{isDragActive && (getAllowChatFlowUploads.data?.isImageUploadAllowed || getAllowChatFlowUploads.data?.isFileUploadAllowed) && (
<Box className='drop-overlay'>
<Typography variant='h2'>Drop here to upload</Typography>
{[
...getAllowChatFlowUploads.data.imgUploadSizeAndTypes,
...getAllowChatFlowUploads.data.fileUploadSizeAndTypes
].map((allowed) => {
{[...getAllowChatFlowUploads.data.imgUploadSizeAndTypes, ...getAllowChatFlowUploads.data.fileUploadSizeAndTypes].map(
(allowed) => {
return (
<>
<Typography variant='subtitle1'>{allowed.fileTypes?.join(', ')}</Typography>
@ -1213,7 +1216,8 @@ export const ChatMessage = ({ open, chatflowid, isAgentCanvas, isDialog, preview
)}
</>
)
})}
}
)}
</Box>
)}
<div ref={ps} className={`${isDialog ? 'cloud-dialog' : 'cloud'}`}>