-
-
Notifications
You must be signed in to change notification settings - Fork 12
fix: include file names in the message #107
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
Conversation
Shiti
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've suggested minor renames to clarify functionality.
|
|
||
| export default function MultimodalInput(props: MultimodalInputProps) { | ||
| const [fileCount, setFileCount] = useState(0) | ||
| const [fileList, setFileList] = useState<string[]>([]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| const [fileList, setFileList] = useState<string[]>([]) | |
| const [fileNames, setFileNames] = useState<string[]>([]) |
| useState<HTMLDivElement>() | ||
| const inputRef = useRef<HTMLDivElement>(null) | ||
| const hasAddedFiles = fileCount > 0 | ||
| const hasAddedFiles = fileList.length > 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| const hasAddedFiles = fileList.length > 0 | |
| const hasAddedFiles = fileNames.length > 0 |
| props.ws.send(formattedMessage) | ||
| setMessageId(getUUID()) | ||
| setFileCount(0) | ||
| setFileList([]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| setFileList([]) | |
| setFileNames([]) |
|
|
||
| function handleFileCountChange(fileCountChange: 1 | -1) { | ||
| setFileCount((prev) => prev + fileCountChange) | ||
| function handleFileListChange(action: 'add' | 'remove', fileName: string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| function handleFileListChange(action: 'add' | 'remove', fileName: string) { | |
| function handleFileUpdates(action: 'add' | 'remove', fileName: string) { |
| uploadFileEndpoint={props.uploadFileEndpoint} | ||
| deleteFileEndpoint={props.deleteFileEndpoint} | ||
| handleFileCountChange={handleFileCountChange} | ||
| handleFileListChange={handleFileListChange} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| handleFileListChange={handleFileListChange} | |
| onFileUpdates={handleFileListChange} |
src/components/types.ts
Outdated
| UploaderProps, | ||
| | 'messageId' | ||
| | 'handleFileCountChange' | ||
| | 'handleFileListChange' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| | 'handleFileListChange' | |
| | 'onFileUpdate' |
| }) | ||
| .catch(() => { | ||
| props.handleFileCountChange(1) | ||
| props.handleFileListChange('add', fileName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| props.handleFileListChange('add', fileName) | |
| props.onFileUpdate('add', fileName) |
| ...fileNamesRef.current, | ||
| [fileName]: fileNamesRef.current[fileName]--, | ||
| } | ||
| props.handleFileListChange('remove', fileName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| props.handleFileListChange('remove', fileName) | |
| props.onFileUpdate('remove', fileName) |
| }) | ||
| .catch((error) => { | ||
| props.handleFileCountChange(-1) | ||
| props.handleFileListChange('remove', fileName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| props.handleFileListChange('remove', fileName) | |
| props.onFileUpdate('remove', fileName) |
| setAddedFiles((prev) => [...prev, newAddedFile]) | ||
|
|
||
| props.handleFileCountChange(1) | ||
| props.handleFileListChange('add', fileName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| props.handleFileListChange('add', fileName) | |
| props.onFileUpdate('add', fileName) |
src/components/types.ts
Outdated
| messageId: string | ||
| /** A function to handle changes in the file count. Parent component should use this to track file count change and handle submit accordingly. */ | ||
| handleFileCountChange: (fileCountChange: 1 | -1) => void | ||
| /** A function to handle changes in the file list. Parent component should use this to track file names and handle submit accordingly. */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| /** A function to handle changes in the file list. Parent component should use this to track file names and handle submit accordingly. */ | |
| /** A function to handle changes in the file list. The parent component should use this to track file names and handle submit accordingly. */ |
Changes
Note: The alert is only be shown in the storybook to show the content being sent.
Before
After