Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/prevent upsert when images are uploaded #3102

Merged
merged 1 commit into from
Aug 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading