From 717a6c90ef65462df93be499a5e838775ebd501e Mon Sep 17 00:00:00 2001 From: Enrico Ros Date: Wed, 18 Sep 2024 17:53:47 -0700 Subject: [PATCH] openFilesForAttaching: await completion (may mean full conversion and AI processing) --- src/common/components/ButtonAttachFiles.tsx | 24 ++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/common/components/ButtonAttachFiles.tsx b/src/common/components/ButtonAttachFiles.tsx index cca3d1f5f..0465124b7 100644 --- a/src/common/components/ButtonAttachFiles.tsx +++ b/src/common/components/ButtonAttachFiles.tsx @@ -7,26 +7,18 @@ import AttachFileRoundedIcon from '@mui/icons-material/AttachFileRounded'; import { KeyStroke } from '~/common/components/KeyStroke'; -const attachFileLegend = - - Attach files
- Drag & drop in chat for faster loads ⚡ - -
; - - export async function openFileForAttaching( multiple: boolean, - onAttachFiles: (files: FileWithHandle[]) => void, -) { + onAttachFiles: (files: FileWithHandle[]) => void | Promise, +): Promise { try { const selectedFiles = await fileOpen({ multiple }); if (selectedFiles) { if (Array.isArray(selectedFiles)) { if (selectedFiles.length) - onAttachFiles(selectedFiles); + await onAttachFiles(selectedFiles); } else { - onAttachFiles([selectedFiles]); + await onAttachFiles([selectedFiles]); } } } catch (error) { @@ -35,6 +27,14 @@ export async function openFileForAttaching( } +const attachFileLegend = + + Attach files
+ Drag & drop in chat for faster loads ⚡ + +
; + + export const ButtonAttachFilesMemo = React.memo(ButtonAttachFiles); function ButtonAttachFiles(props: { isMobile?: boolean, fullWidth?: boolean, multiple?: boolean, noToolTip?: boolean, onAttachFiles: (files: FileWithHandle[]) => void }) {