Skip to content

Commit

Permalink
Bugfix/prevent upsert when images are uploaded (FlowiseAI#3102)
Browse files Browse the repository at this point in the history
prevent upsert when images are uploaded
  • Loading branch information
HenryHengZJ authored and Alves, Patrick committed Sep 3, 2024
1 parent 28aef05 commit ec762de
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions packages/ui/src/views/chatmessage/ChatMessage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,10 @@ export const ChatMessage = ({ open, chatflowid, isAgentCanvas, isDialog, preview
}
const reader = new FileReader()
const { name } = file
uploadedFiles.push(file)
// Only add files
if (!imageUploadAllowedTypes.includes(file.type)) {
uploadedFiles.push(file)
}
files.push(
new Promise((resolve) => {
reader.onload = (evt) => {
Expand Down Expand Up @@ -340,7 +343,10 @@ export const ChatMessage = ({ open, chatflowid, isAgentCanvas, isDialog, preview
if (isFileAllowedForUpload(file) === false) {
return
}
uploadedFiles.push(file)
// Only add files
if (!imageUploadAllowedTypes.includes(file.type)) {
uploadedFiles.push(file)
}
const reader = new FileReader()
const { name } = file
files.push(
Expand Down Expand Up @@ -1197,14 +1203,11 @@ export const ChatMessage = ({ open, chatflowid, isAgentCanvas, isDialog, preview
onDrop={handleDrop}
/>
)}
{isDragActive &&
(getAllowChatFlowUploads.data?.isImageUploadAllowed || getAllowChatFlowUploads.data?.isFileAllowedForUpload) && (
<Box className='drop-overlay'>
<Typography variant='h2'>Drop here to upload</Typography>
{[
...getAllowChatFlowUploads.data.imgUploadSizeAndTypes,
...getAllowChatFlowUploads.data.fileUploadSizeAndTypes
].map((allowed) => {
{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) => {
return (
<>
<Typography variant='subtitle1'>{allowed.fileTypes?.join(', ')}</Typography>
Expand All @@ -1213,9 +1216,10 @@ export const ChatMessage = ({ open, chatflowid, isAgentCanvas, isDialog, preview
)}
</>
)
})}
</Box>
)}
}
)}
</Box>
)}
<div ref={ps} className={`${isDialog ? 'cloud-dialog' : 'cloud'}`}>
<div id='messagelist' className={'messagelist'}>
{messages &&
Expand Down

0 comments on commit ec762de

Please sign in to comment.