mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-24 12:20:14 +01:00
fix: bring back proper deletion handling we lost with refactor for onRemoveHandler
This commit is contained in:
parent
e062ed5832
commit
013c002cbb
5 changed files with 20 additions and 0 deletions
|
|
@ -184,6 +184,7 @@ const CreatePromptForm = ({
|
|||
onFilesChange={setFiles}
|
||||
handleFileChange={handleFileChange}
|
||||
disabled={isSubmitting}
|
||||
onFileChange={() => {}}
|
||||
/>
|
||||
<Description
|
||||
onValueChange={(value) => methods.setValue('oneliner', value)}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ export default function PromptFile({
|
|||
fileFilter,
|
||||
isRTL = false,
|
||||
Wrapper,
|
||||
onFileChange,
|
||||
}: {
|
||||
files: Map<string, ExtendedFile> | undefined;
|
||||
abortUpload?: () => void;
|
||||
|
|
@ -21,6 +22,7 @@ export default function PromptFile({
|
|||
fileFilter?: (file: ExtendedFile) => boolean;
|
||||
isRTL?: boolean;
|
||||
Wrapper?: React.FC<{ children: React.ReactNode }>;
|
||||
onFileChange?: (files: ExtendedFile[]) => void;
|
||||
}) {
|
||||
const localize = useLocalize();
|
||||
const { showToast } = useToastContext();
|
||||
|
|
@ -101,6 +103,11 @@ export default function PromptFile({
|
|||
if (file.temp_file_id) {
|
||||
updatedFiles.delete(file.temp_file_id);
|
||||
}
|
||||
|
||||
// Call onFileChange with the updated files array
|
||||
const updatedFilesArray = Array.from(updatedFiles.values());
|
||||
onFileChange?.(updatedFilesArray);
|
||||
|
||||
return updatedFiles;
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -12,11 +12,13 @@ const PromptFiles = ({
|
|||
onFilesChange,
|
||||
handleFileChange,
|
||||
disabled,
|
||||
onFileChange,
|
||||
}: {
|
||||
files: ExtendedFile[];
|
||||
onFilesChange?: (files: ExtendedFile[]) => void;
|
||||
handleFileChange?: (event: React.ChangeEvent<HTMLInputElement>, toolResource?: string) => void;
|
||||
disabled?: boolean;
|
||||
onFileChange?: (files: ExtendedFile[]) => void;
|
||||
}) => {
|
||||
const localize = useLocalize();
|
||||
|
||||
|
|
@ -63,6 +65,7 @@ const PromptFiles = ({
|
|||
onFilesChange?.(newFiles);
|
||||
}}
|
||||
setFilesLoading={() => {}}
|
||||
onFileChange={onFileChange}
|
||||
Wrapper={({ children }) => <div className="flex flex-wrap gap-2">{children}</div>}
|
||||
/>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -544,6 +544,12 @@ const PromptForm = () => {
|
|||
onFilesChange={setFiles}
|
||||
handleFileChange={handleFileChange}
|
||||
disabled={!canEdit}
|
||||
onFileChange={(updatedFiles) => {
|
||||
if (canEdit && selectedPrompt) {
|
||||
const currentPromptText = getValues('prompt');
|
||||
onSave(currentPromptText, updatedFiles);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<Description
|
||||
initialValue={group.oneliner ?? ''}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ interface PromptVariablesAndFilesProps {
|
|||
handleFileChange?: (event: React.ChangeEvent<HTMLInputElement>, toolResource?: string) => void;
|
||||
disabled?: boolean;
|
||||
showVariablesInfo?: boolean;
|
||||
onFileChange?: (files: ExtendedFile[]) => void;
|
||||
}
|
||||
|
||||
const PromptVariablesAndFiles: React.FC<PromptVariablesAndFilesProps> = ({
|
||||
|
|
@ -19,6 +20,7 @@ const PromptVariablesAndFiles: React.FC<PromptVariablesAndFilesProps> = ({
|
|||
handleFileChange,
|
||||
disabled,
|
||||
showVariablesInfo = true,
|
||||
onFileChange,
|
||||
}) => {
|
||||
return (
|
||||
<div className="grid grid-cols-1 gap-4 lg:grid-cols-2 lg:items-stretch">
|
||||
|
|
@ -34,6 +36,7 @@ const PromptVariablesAndFiles: React.FC<PromptVariablesAndFilesProps> = ({
|
|||
onFilesChange={onFilesChange}
|
||||
handleFileChange={handleFileChange}
|
||||
disabled={disabled}
|
||||
onFileChange={onFileChange}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue