mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-29 06:38:50 +01:00
debugging convo state, useSWR now within convos component
This commit is contained in:
parent
0e5c7c7721
commit
dcf4f2a524
6 changed files with 213 additions and 15 deletions
|
|
@ -1,10 +1,16 @@
|
|||
import React, { useState } from 'react';
|
||||
import { useSelector } from 'react-redux';
|
||||
import Conversation from './Conversation';
|
||||
import { swr } from '~/utils/fetchers';
|
||||
import useDidMountEffect from '~/hooks/useDidMountEffect';
|
||||
|
||||
export default function Conversations({ conversations }) {
|
||||
export default function Conversations() {
|
||||
const { data, error, isLoading, mutate } = swr('http://localhost:3050/convos');
|
||||
const conversations = data;
|
||||
const [isHovering, setIsHovering] = useState(false);
|
||||
const { conversationId } = useSelector((state) => state.convo);
|
||||
|
||||
useDidMountEffect(() => mutate(), [conversationId]);
|
||||
// const currentRef = useRef(null);
|
||||
|
||||
// const scrollToTop = () => {
|
||||
|
|
|
|||
|
|
@ -3,14 +3,14 @@ import NewChat from './NewChat';
|
|||
import Conversations from '../Conversations';
|
||||
import NavLinks from './NavLinks';
|
||||
|
||||
export default function Nav({ conversations, conversationId }) {
|
||||
export default function Nav() {
|
||||
return (
|
||||
<div className="dark hidden bg-gray-900 md:fixed md:inset-y-0 md:flex md:w-[260px] md:flex-col">
|
||||
<div className="flex h-full min-h-0 flex-col ">
|
||||
<div className="scrollbar-trigger flex h-full w-full flex-1 items-start border-white/20">
|
||||
<nav className="flex h-full flex-1 flex-col space-y-1 p-2">
|
||||
<NewChat />
|
||||
<Conversations conversations={conversations} />
|
||||
<Conversations />
|
||||
<NavLinks />
|
||||
</nav>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -38,12 +38,14 @@ export default function TextChat({ messages, reloadConvos }) {
|
|||
const convoHandler = (data) => {
|
||||
console.log('in convo handler');
|
||||
if (convo.conversationId === null && convo.parentMessageId === null) {
|
||||
const { title, conversationId, parentMessageId } = data;
|
||||
const { title, conversationId, id } = data;
|
||||
console.log('convo is null');
|
||||
dispatch(setConversation({ title, conversationId, parentMessageId: data.id }));
|
||||
console.log('title, convoId, id', title, conversationId, id);
|
||||
dispatch(setConversation({ title, conversationId, parentMessageId: id }));
|
||||
console.log('convo after dispatch', convo);
|
||||
}
|
||||
|
||||
reloadConvos();
|
||||
// reloadConvos();
|
||||
dispatch(setSubmitState(false));
|
||||
};
|
||||
|
||||
|
|
@ -111,7 +113,7 @@ export default function TextChat({ messages, reloadConvos }) {
|
|||
errorMessage={errorMessage}
|
||||
/>
|
||||
) : (
|
||||
<div className="relative flex w-full flex-grow flex-col rounded-md border border-black/10 bg-white py-2 shadow-md dark:border-gray-900/50 dark:bg-gray-700 dark:text-white dark:shadow-lg md:py-3 md:pl-4">
|
||||
<div className="relative flex w-full flex-grow flex-col rounded-md border border-black/10 bg-white py-2 shadow-[0_0_10px_rgba(0,0,0,0.10)] dark:border-gray-900/50 dark:bg-gray-700 dark:text-white dark:shadow-[0_0_15px_rgba(0,0,0,0.10)] md:py-3 md:pl-4">
|
||||
<TextareaAutosize
|
||||
tabIndex="0"
|
||||
// style={{maxHeight: '200px', height: '24px', overflowY: 'hidden'}}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue