update readme, setup files, and clear convo bug

This commit is contained in:
Danny Avila 2023-03-07 14:43:55 -05:00
parent 5ad32e211f
commit a8eaf2452a
6 changed files with 28 additions and 17 deletions

View file

@ -1,27 +1,31 @@
import React from 'react';
import TrashIcon from '../svg/TrashIcon';
import { useSWRConfig } from "swr"
import { useSWRConfig } from 'swr';
import manualSWR from '~/utils/fetchers';
import { useDispatch } from 'react-redux';
import { setConversation } from '~/store/convoSlice';
import { setConversation, removeAll } from '~/store/convoSlice';
import { setMessages } from '~/store/messageSlice';
export default function ClearConvos() {
const dispatch = useDispatch();
const { mutate } = useSWRConfig()
const { mutate } = useSWRConfig();
const { trigger } = manualSWR(
`http://localhost:3080/api/convos/clear`,
'post',
() => {
dispatch(setMessages([]));
dispatch(setConversation({ error: false, title: 'New chat', conversationId: null, parentMessageId: null }));
mutate(`http://localhost:3080/api/convos`);
}
);
const { trigger } = manualSWR(`http://localhost:3080/api/convos/clear`, 'post', () => {
dispatch(setMessages([]));
dispatch(
setConversation({
error: false,
title: 'New chat',
conversationId: null,
parentMessageId: null
})
);
mutate(`http://localhost:3080/api/convos`);
});
const clickHandler = () => {
console.log('Clearing conversations...');
dispatch(removeAll());
trigger({});
};