mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-01-08 11:38:51 +01:00
add RQ to clear all conversations
This commit is contained in:
parent
94e0636b32
commit
dd0a91a9f6
3 changed files with 19 additions and 36 deletions
|
|
@ -1,27 +1,27 @@
|
|||
import React from 'react';
|
||||
import { useEffect } from 'react';
|
||||
import store from '~/store';
|
||||
import TrashIcon from '../svg/TrashIcon';
|
||||
import { useSWRConfig } from 'swr';
|
||||
import manualSWR from '~/utils/fetchers';
|
||||
import { Dialog, DialogTrigger } from '../ui/Dialog.tsx';
|
||||
import DialogTemplate from '../ui/DialogTemplate';
|
||||
import { useDeleteConversationMutation } from '~/data-provider';
|
||||
|
||||
export default function ClearConvos() {
|
||||
const { newConversation } = store.useConversation();
|
||||
const { refreshConversations } = store.useConversations();
|
||||
const { mutate } = useSWRConfig();
|
||||
|
||||
const { trigger } = manualSWR(`/api/convos/clear`, 'post', () => {
|
||||
newConversation();
|
||||
refreshConversations();
|
||||
mutate(`/api/convos`);
|
||||
});
|
||||
const clearConvosMutation = useDeleteConversationMutation();
|
||||
|
||||
const clickHandler = () => {
|
||||
console.log('Clearing conversations...');
|
||||
trigger({});
|
||||
clearConvosMutation.mutate({});
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (clearConvosMutation.isSuccess) {
|
||||
newConversation();
|
||||
refreshConversations();
|
||||
}
|
||||
}, [clearConvosMutation.isSuccess]);
|
||||
|
||||
return (
|
||||
<Dialog>
|
||||
<DialogTrigger asChild>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue