Skip to content

Commit

Permalink
fix: improve code formatting and consistency in PureMultimodalInput c…
Browse files Browse the repository at this point in the history
…omponent
  • Loading branch information
athrael-soju committed Dec 19, 2024
1 parent 4b2300e commit 1156322
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions components/multimodal-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ function PureMultimodalInput({
setMessages: Dispatch<SetStateAction<Array<Message>>>;
append: (
message: Message | CreateMessage,
chatRequestOptions?: ChatRequestOptions
chatRequestOptions?: ChatRequestOptions,
) => Promise<string | null | undefined>;
handleSubmit: (
event?: {
preventDefault?: () => void;
},
chatRequestOptions?: ChatRequestOptions
chatRequestOptions?: ChatRequestOptions,
) => void;
className?: string;
}) {
Expand All @@ -77,15 +77,13 @@ function PureMultimodalInput({
const adjustHeight = () => {
if (textareaRef.current) {
textareaRef.current.style.height = 'auto';
textareaRef.current.style.height = `${
textareaRef.current.scrollHeight + 2
}px`;
textareaRef.current.style.height = `${textareaRef.current.scrollHeight + 2}px`;
}
};

const [localStorageInput, setLocalStorageInput] = useLocalStorage(
'input',
''
'',
);

useEffect(() => {
Expand Down Expand Up @@ -171,7 +169,7 @@ function PureMultimodalInput({
const uploadPromises = files.map((file) => uploadFile(file));
const uploadedAttachments = await Promise.all(uploadPromises);
const successfullyUploadedAttachments = uploadedAttachments.filter(
(attachment) => attachment !== undefined
(attachment) => attachment !== undefined,
);

setAttachments((currentAttachments) => [
Expand All @@ -184,7 +182,7 @@ function PureMultimodalInput({
setUploadQueue([]);
}
},
[setAttachments]
[setAttachments],
);

return (
Expand Down Expand Up @@ -231,13 +229,12 @@ function PureMultimodalInput({
onChange={handleInput}
className={cx(
'min-h-[24px] max-h-[calc(75dvh)] overflow-hidden resize-none rounded-2xl !text-base bg-muted pb-10 dark:border-zinc-700',
className
className,
)}
rows={2}
autoFocus
onKeyDown={(event) => {
// Only handle Enter submission on desktop
if (event.key === 'Enter' && !event.shiftKey && width > 768) {
if (event.key === 'Enter' && !event.shiftKey) {
event.preventDefault();

if (isLoading) {
Expand Down Expand Up @@ -276,7 +273,7 @@ export const MultimodalInput = memo(
if (!equal(prevProps.attachments, nextProps.attachments)) return false;

return true;
}
},
);

function PureAttachmentsButton({
Expand Down

0 comments on commit 1156322

Please sign in to comment.