From c19957dc71decdbc479e1ae417322cc175d77cf1 Mon Sep 17 00:00:00 2001 From: amcdnl Date: Tue, 13 Aug 2024 04:15:26 -0400 Subject: [PATCH] fix comments --- src/ChatInput/ChatInput.tsx | 6 +-- stories/Console.stories.tsx | 103 ------------------------------------ 2 files changed, 3 insertions(+), 106 deletions(-) diff --git a/src/ChatInput/ChatInput.tsx b/src/ChatInput/ChatInput.tsx index 782d8bb..9477f45 100644 --- a/src/ChatInput/ChatInput.tsx +++ b/src/ChatInput/ChatInput.tsx @@ -68,10 +68,10 @@ export const ChatInput = forwardRef(({ const inputRef = useRef(null); useEffect(() => { - if(inputRef && inputRef.current) { - inputRef.current.focus() + if(inputRef.current) { + inputRef.current.focus(); } - }, [activeSessionId, inputRef]) + }, [activeSessionId, inputRef]); useImperativeHandle(ref, () => ({ focus: () => { diff --git a/stories/Console.stories.tsx b/stories/Console.stories.tsx index e49da22..785ed95 100644 --- a/stories/Console.stories.tsx +++ b/stories/Console.stories.tsx @@ -1093,106 +1093,3 @@ export const ImageFiles = () => { ); }; - -export const Working = () => { - const [activeId, setActiveId] = useState(); - const [sessions, setSessions] = useState([]); - const [loading, setLoading] = useState(false); - const [count, setCount] = useState(sessions.length + 1); - - const handleNewSession = () => { - const newId = count.toLocaleString(); - setSessions([ - ...sessions, - { - id: newId, - title: `New Session #${newId}`, - createdAt: new Date(), - updatedAt: new Date(), - conversations: [] - } - ]); - setActiveId(newId); - setCount(count + 1); - }; - - const handleDelete = (id: string) => { - const updated = sessions.filter(s => s.id !== id); - setSessions([...updated]); - }; - - const handleNewMessage = (message: string) => { - setLoading(true); - const curr = sessions.find(s => s.id === activeId); - if (curr) { - const newMessage: Conversation = { - id: `${curr.id}-${curr.conversations.length}`, - question: message, - response: 'this is an example response', - createdAt: new Date(), - updatedAt: new Date() - }; - const updated = { - ...curr, - conversations: [...curr.conversations, newMessage] - }; - setSessions([...sessions.filter(s => s.id !== activeId), updated]); - } else { - const newId = '1'; - const newSession: Session = { - id: newId, - title: message.length > 28 ? `${message.substring(0, 25)}...` : message, - createdAt: new Date(), - updatedAt: new Date(), - conversations: [ - { - id: `${newId}-1`, - question: message, - response: 'this is an example response', - createdAt: new Date(), - updatedAt: new Date() - } - ] - }; - setSessions([newSession]); - setActiveId(newId); - } - setLoading(false); - }; - - return ( -
- - - - - - - - - - - -
- ); -};