mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-02-26 12:24:10 +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}
|
onFilesChange={setFiles}
|
||||||
handleFileChange={handleFileChange}
|
handleFileChange={handleFileChange}
|
||||||
disabled={isSubmitting}
|
disabled={isSubmitting}
|
||||||
|
onFileChange={() => {}}
|
||||||
/>
|
/>
|
||||||
<Description
|
<Description
|
||||||
onValueChange={(value) => methods.setValue('oneliner', value)}
|
onValueChange={(value) => methods.setValue('oneliner', value)}
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ export default function PromptFile({
|
||||||
fileFilter,
|
fileFilter,
|
||||||
isRTL = false,
|
isRTL = false,
|
||||||
Wrapper,
|
Wrapper,
|
||||||
|
onFileChange,
|
||||||
}: {
|
}: {
|
||||||
files: Map<string, ExtendedFile> | undefined;
|
files: Map<string, ExtendedFile> | undefined;
|
||||||
abortUpload?: () => void;
|
abortUpload?: () => void;
|
||||||
|
|
@ -21,6 +22,7 @@ export default function PromptFile({
|
||||||
fileFilter?: (file: ExtendedFile) => boolean;
|
fileFilter?: (file: ExtendedFile) => boolean;
|
||||||
isRTL?: boolean;
|
isRTL?: boolean;
|
||||||
Wrapper?: React.FC<{ children: React.ReactNode }>;
|
Wrapper?: React.FC<{ children: React.ReactNode }>;
|
||||||
|
onFileChange?: (files: ExtendedFile[]) => void;
|
||||||
}) {
|
}) {
|
||||||
const localize = useLocalize();
|
const localize = useLocalize();
|
||||||
const { showToast } = useToastContext();
|
const { showToast } = useToastContext();
|
||||||
|
|
@ -101,6 +103,11 @@ export default function PromptFile({
|
||||||
if (file.temp_file_id) {
|
if (file.temp_file_id) {
|
||||||
updatedFiles.delete(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;
|
return updatedFiles;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -12,11 +12,13 @@ const PromptFiles = ({
|
||||||
onFilesChange,
|
onFilesChange,
|
||||||
handleFileChange,
|
handleFileChange,
|
||||||
disabled,
|
disabled,
|
||||||
|
onFileChange,
|
||||||
}: {
|
}: {
|
||||||
files: ExtendedFile[];
|
files: ExtendedFile[];
|
||||||
onFilesChange?: (files: ExtendedFile[]) => void;
|
onFilesChange?: (files: ExtendedFile[]) => void;
|
||||||
handleFileChange?: (event: React.ChangeEvent<HTMLInputElement>, toolResource?: string) => void;
|
handleFileChange?: (event: React.ChangeEvent<HTMLInputElement>, toolResource?: string) => void;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
|
onFileChange?: (files: ExtendedFile[]) => void;
|
||||||
}) => {
|
}) => {
|
||||||
const localize = useLocalize();
|
const localize = useLocalize();
|
||||||
|
|
||||||
|
|
@ -63,6 +65,7 @@ const PromptFiles = ({
|
||||||
onFilesChange?.(newFiles);
|
onFilesChange?.(newFiles);
|
||||||
}}
|
}}
|
||||||
setFilesLoading={() => {}}
|
setFilesLoading={() => {}}
|
||||||
|
onFileChange={onFileChange}
|
||||||
Wrapper={({ children }) => <div className="flex flex-wrap gap-2">{children}</div>}
|
Wrapper={({ children }) => <div className="flex flex-wrap gap-2">{children}</div>}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -544,6 +544,12 @@ const PromptForm = () => {
|
||||||
onFilesChange={setFiles}
|
onFilesChange={setFiles}
|
||||||
handleFileChange={handleFileChange}
|
handleFileChange={handleFileChange}
|
||||||
disabled={!canEdit}
|
disabled={!canEdit}
|
||||||
|
onFileChange={(updatedFiles) => {
|
||||||
|
if (canEdit && selectedPrompt) {
|
||||||
|
const currentPromptText = getValues('prompt');
|
||||||
|
onSave(currentPromptText, updatedFiles);
|
||||||
|
}
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
<Description
|
<Description
|
||||||
initialValue={group.oneliner ?? ''}
|
initialValue={group.oneliner ?? ''}
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ interface PromptVariablesAndFilesProps {
|
||||||
handleFileChange?: (event: React.ChangeEvent<HTMLInputElement>, toolResource?: string) => void;
|
handleFileChange?: (event: React.ChangeEvent<HTMLInputElement>, toolResource?: string) => void;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
showVariablesInfo?: boolean;
|
showVariablesInfo?: boolean;
|
||||||
|
onFileChange?: (files: ExtendedFile[]) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const PromptVariablesAndFiles: React.FC<PromptVariablesAndFilesProps> = ({
|
const PromptVariablesAndFiles: React.FC<PromptVariablesAndFilesProps> = ({
|
||||||
|
|
@ -19,6 +20,7 @@ const PromptVariablesAndFiles: React.FC<PromptVariablesAndFilesProps> = ({
|
||||||
handleFileChange,
|
handleFileChange,
|
||||||
disabled,
|
disabled,
|
||||||
showVariablesInfo = true,
|
showVariablesInfo = true,
|
||||||
|
onFileChange,
|
||||||
}) => {
|
}) => {
|
||||||
return (
|
return (
|
||||||
<div className="grid grid-cols-1 gap-4 lg:grid-cols-2 lg:items-stretch">
|
<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}
|
onFilesChange={onFilesChange}
|
||||||
handleFileChange={handleFileChange}
|
handleFileChange={handleFileChange}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
|
onFileChange={onFileChange}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue