mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 08:50:15 +01:00
🛠️ refactor: Handle .webp, Improve File Life Cycle 📁 (#1213)
* fix: handle webp images correctly * refactor: use the userPath from the start of the filecycle to avoid handling the blob, whose loading may fail upon user request * refactor: delete temp files on reload and new chat
This commit is contained in:
parent
650759306d
commit
cc39074e0a
15 changed files with 160 additions and 66 deletions
|
|
@ -15,7 +15,8 @@ import type {
|
|||
TConversation,
|
||||
TGetConversationsResponse,
|
||||
} from 'librechat-data-provider';
|
||||
import type { TAskFunction, ExtendedFile } from '~/common';
|
||||
import type { TAskFunction } from '~/common';
|
||||
import useSetFilesToDelete from './useSetFilesToDelete';
|
||||
import { useAuthContext } from './AuthContext';
|
||||
import useNewConvo from './useNewConvo';
|
||||
import useUserKey from './useUserKey';
|
||||
|
|
@ -23,8 +24,9 @@ import store from '~/store';
|
|||
|
||||
// this to be set somewhere else
|
||||
export default function useChatHelpers(index = 0, paramId: string | undefined) {
|
||||
const [files, setFiles] = useState(new Map<string, ExtendedFile>());
|
||||
const [files, setFiles] = useRecoilState(store.filesByIndex(index));
|
||||
const [filesLoading, setFilesLoading] = useState(false);
|
||||
const setFilesToDelete = useSetFilesToDelete();
|
||||
|
||||
const queryClient = useQueryClient();
|
||||
const { isAuthenticated } = useAuthContext();
|
||||
|
|
@ -190,6 +192,7 @@ export default function useChatHelpers(index = 0, paramId: string | undefined) {
|
|||
if (reuseFiles && parentMessage.files?.length) {
|
||||
currentMsg.files = parentMessage.files;
|
||||
setFiles(new Map());
|
||||
setFilesToDelete({});
|
||||
} else if (files.size > 0) {
|
||||
currentMsg.files = Array.from(files.values()).map((file) => ({
|
||||
file_id: file.file_id,
|
||||
|
|
@ -199,6 +202,7 @@ export default function useChatHelpers(index = 0, paramId: string | undefined) {
|
|||
width: file.width,
|
||||
}));
|
||||
setFiles(new Map());
|
||||
setFilesToDelete({});
|
||||
}
|
||||
|
||||
// construct the placeholder response message
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue