mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-18 17:30:16 +01:00
✍️ feat: Automatic Save and Restore for Chat (#2942)
* feat: added "Save draft locally" to Message settings * feat: add hook to save chat input as draft every second * fix: use filepath if the file does not have a preview prop * fix: not to delete temporary files when navigating to a new chat * chore: translations * chore: import order * chore: import order --------- Co-authored-by: Danny Avila <danacordially@gmail.com> Co-authored-by: Danny Avila <danny@librechat.ai>
This commit is contained in:
parent
e9bbf39618
commit
29e71e98ad
22 changed files with 345 additions and 5 deletions
|
|
@ -48,6 +48,7 @@ const useNewConvo = (index = 0) => {
|
|||
const timeoutIdRef = useRef<NodeJS.Timeout>();
|
||||
const assistantsListMap = useAssistantListMap();
|
||||
const { pauseGlobalAudio } = usePauseGlobalAudio(index);
|
||||
const saveDrafts = useRecoilValue<boolean>(store.saveDrafts);
|
||||
|
||||
const { mutateAsync } = useDeleteFilesMutation({
|
||||
onSuccess: () => {
|
||||
|
|
@ -211,14 +212,22 @@ const useNewConvo = (index = 0) => {
|
|||
setFiles(new Map());
|
||||
localStorage.setItem(LocalStorageKeys.FILES_TO_DELETE, JSON.stringify({}));
|
||||
|
||||
if (filesToDelete.length > 0) {
|
||||
if (!saveDrafts && filesToDelete.length > 0) {
|
||||
mutateAsync({ files: filesToDelete });
|
||||
}
|
||||
}
|
||||
|
||||
switchToConversation(conversation, preset, modelsData, buildDefault, keepLatestMessage);
|
||||
},
|
||||
[pauseGlobalAudio, switchToConversation, mutateAsync, setFiles, files, startupConfig],
|
||||
[
|
||||
pauseGlobalAudio,
|
||||
startupConfig,
|
||||
saveDrafts,
|
||||
switchToConversation,
|
||||
files,
|
||||
setFiles,
|
||||
mutateAsync,
|
||||
],
|
||||
);
|
||||
|
||||
return {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue