openFilesForAttaching: await completion (may mean full conversion and AI processing)

This commit is contained in:
Enrico Ros
2024-09-18 17:53:47 -07:00
parent f4b1b292b7
commit 717a6c90ef
+12 -12
View File
@@ -7,26 +7,18 @@ import AttachFileRoundedIcon from '@mui/icons-material/AttachFileRounded';
import { KeyStroke } from '~/common/components/KeyStroke';
const attachFileLegend =
<Box sx={{ px: 1, py: 0.75, lineHeight: '1.5rem' }}>
<b>Attach files</b><br />
Drag & drop in chat for faster loads
<KeyStroke combo='Ctrl + Shift + F' sx={{ mt: 1, mb: 0.5 }} />
</Box>;
export async function openFileForAttaching(
multiple: boolean,
onAttachFiles: (files: FileWithHandle[]) => void,
) {
onAttachFiles: (files: FileWithHandle[]) => void | Promise<void>,
): Promise<void> {
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 =
<Box sx={{ px: 1, py: 0.75, lineHeight: '1.5rem' }}>
<b>Attach files</b><br />
Drag & drop in chat for faster loads
<KeyStroke combo='Ctrl + Shift + F' sx={{ mt: 1, mb: 0.5 }} />
</Box>;
export const ButtonAttachFilesMemo = React.memo(ButtonAttachFiles);
function ButtonAttachFiles(props: { isMobile?: boolean, fullWidth?: boolean, multiple?: boolean, noToolTip?: boolean, onAttachFiles: (files: FileWithHandle[]) => void }) {