mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-18 01:10:14 +01:00
fix: deletion + version updates not working properly
This commit is contained in:
parent
797fdf4286
commit
d4fd0047cb
1 changed files with 19 additions and 5 deletions
|
|
@ -38,7 +38,15 @@ export const usePromptFileHandling = (params?: UsePromptFileHandling) => {
|
||||||
const [filesLoading, setFilesLoading] = useState(false);
|
const [filesLoading, setFilesLoading] = useState(false);
|
||||||
const abortControllerRef = useRef<AbortController | null>(null);
|
const abortControllerRef = useRef<AbortController | null>(null);
|
||||||
|
|
||||||
const deleteFileMutation = useDeleteFilesMutation();
|
const deleteFileMutation = useDeleteFilesMutation({
|
||||||
|
onSuccess: () => {
|
||||||
|
params?.onFileChange?.();
|
||||||
|
},
|
||||||
|
onError: (error) => {
|
||||||
|
logger.error('Error deleting file:', error);
|
||||||
|
params?.onFileChange?.();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
const uploadFile = useUploadFileMutation({
|
const uploadFile = useUploadFileMutation({
|
||||||
onSuccess: (data) => {
|
onSuccess: (data) => {
|
||||||
|
|
@ -53,7 +61,13 @@ export const usePromptFileHandling = (params?: UsePromptFileHandling) => {
|
||||||
filepath: data.filepath,
|
filepath: data.filepath,
|
||||||
progress: 1,
|
progress: 1,
|
||||||
attached: true,
|
attached: true,
|
||||||
preview: file.preview,
|
preview: data.filepath || file.preview, // Use filepath for preview if available
|
||||||
|
filename: data.filename || file.filename,
|
||||||
|
type: data.type || file.type,
|
||||||
|
size: data.bytes || file.size,
|
||||||
|
width: data.width || file.width,
|
||||||
|
height: data.height || file.height,
|
||||||
|
source: data.source || file.source,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return file;
|
return file;
|
||||||
|
|
@ -65,6 +79,9 @@ export const usePromptFileHandling = (params?: UsePromptFileHandling) => {
|
||||||
message: 'File uploaded successfully',
|
message: 'File uploaded successfully',
|
||||||
status: 'success',
|
status: 'success',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Call the onFileChange callback to trigger save
|
||||||
|
params?.onFileChange?.();
|
||||||
},
|
},
|
||||||
onError: (error, body) => {
|
onError: (error, body) => {
|
||||||
logger.error('File upload error:', error);
|
logger.error('File upload error:', error);
|
||||||
|
|
@ -226,9 +243,6 @@ export const usePromptFileHandling = (params?: UsePromptFileHandling) => {
|
||||||
return true; // Keep this file
|
return true; // Keep this file
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Call the onFileChange callback to trigger save
|
|
||||||
params?.onFileChange?.();
|
|
||||||
},
|
},
|
||||||
[deleteFileMutation, params?.onFileChange],
|
[deleteFileMutation, params?.onFileChange],
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue