clear all convos in progress, async code refactored in debugging warning

This commit is contained in:
Daniel Avila 2023-02-07 19:07:48 -05:00
parent 053368646d
commit 511ac948b4
10 changed files with 84 additions and 65 deletions

View file

@ -0,0 +1,30 @@
import React from 'react';
import NavLink from './NavLink';
import TrashIcon from '../svg/TrashIcon';
import manualSWR from '~/utils/fetchers';
import { useDispatch } from 'react-redux';
import { setConversation } from '~/store/convoSlice';
import { setMessages } from '~/store/messageSlice';
export default function ClearConvos() {
const dispatch = useDispatch();
const { trigger, isMutating } = manualSWR(
'http://localhost:3050/clear_convos',
'post',
() => {
dispatch(setMessages([]));
dispatch(setConversation({ conversationId: null, parentMessageId: null }));
}
);
const clickHandler = () => trigger({});
return (
<NavLink
svg={TrashIcon}
text="Clear conversations"
onClick={clickHandler}
/>
);
}