mirror of
https://github.com/enricoros/big-AGI.git
synced 2026-05-10 21:50:14 -07:00
openFilesForAttaching: await completion (may mean full conversion and AI processing)
This commit is contained in:
@@ -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 }) {
|
||||
|
||||
Reference in New Issue
Block a user