mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-01-21 17:56:13 +01:00
clear all convos in progress, async code refactored in debugging warning
This commit is contained in:
parent
053368646d
commit
511ac948b4
10 changed files with 84 additions and 65 deletions
30
src/components/Nav/ClearConvos.jsx
Normal file
30
src/components/Nav/ClearConvos.jsx
Normal 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}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,14 +1,19 @@
|
|||
import React from 'react';
|
||||
|
||||
export default function NavLink({ svg, text, clickHandler}) {
|
||||
// const props
|
||||
// if (clickHandler) {
|
||||
export default function NavLink({ svg, text, clickHandler }) {
|
||||
const props = {
|
||||
className:
|
||||
'flex cursor-pointer items-center gap-3 rounded-md py-3 px-3 text-sm text-white transition-colors duration-200 hover:bg-gray-500/10'
|
||||
};
|
||||
|
||||
// }
|
||||
// return (
|
||||
// <a {clickHandler && onClick={clickHandler}} className="flex cursor-pointer items-center gap-3 rounded-md py-3 px-3 text-sm text-white transition-colors duration-200 hover:bg-gray-500/10">
|
||||
// {svg()}
|
||||
// {text}
|
||||
// </a>
|
||||
// );
|
||||
if (clickHandler) {
|
||||
props.onClick = clickHandler;
|
||||
}
|
||||
|
||||
return (
|
||||
<a {...props}>
|
||||
{svg()}
|
||||
{text}
|
||||
</a>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,34 +1,13 @@
|
|||
import React from 'react';
|
||||
import ClearConvos from './ClearConvos';
|
||||
import NavLink from './NavLink';
|
||||
import TrashIcon from '../svg/TrashIcon';
|
||||
import DarkModeIcon from '../svg/DarkModeIcon';
|
||||
import LogOutIcon from '../svg/LogOutIcon';
|
||||
import manualSWR from '~/utils/fetchers';
|
||||
import { useDispatch } from 'react-redux';
|
||||
import { setConversation } from '~/store/convoSlice';
|
||||
import { setMessages } from '~/store/messageSlice';
|
||||
|
||||
export default function NavLinks() {
|
||||
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}
|
||||
/>
|
||||
<ClearConvos />
|
||||
<NavLink
|
||||
svg={DarkModeIcon}
|
||||
text="Dark mode"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue