diff --git a/app/backend/InputOutputHandler.tsx b/app/backend/InputOutputHandler.tsx index 1a4817b..d40f9fb 100644 --- a/app/backend/InputOutputHandler.tsx +++ b/app/backend/InputOutputHandler.tsx @@ -14,7 +14,7 @@ const InputOutputBackend: React.FC = () => { } // Define state variables for user preferences and messages - const [chatHistory, setSelectedIndex, setChatHistory, updateMessage] = useChatHistory() + const [chatHistory, setChatHistory, setSelectedIndex, updateMessage] = useChatHistory() const [preferredCurrency, setPreferredCurrency] = useState("USD"); const [preferredLanguage, setPreferredLanguage] = useState("english"); const [timeFormat, setTimeFormat] = useState("24-hour"); diff --git a/app/components/History.tsx b/app/components/History.tsx index 0aae50f..b3cf197 100644 --- a/app/components/History.tsx +++ b/app/components/History.tsx @@ -2,13 +2,18 @@ import React, { useState } from 'react'; import { useChatHistory } from '../hooks/useChatHistory'; const History: React.FC = () => { - const [chatHistory, setSelectedIndex] = useChatHistory() + const [chatHistory, setChatHistory, setSelectedIndex] = useChatHistory() const [isEditing, setIsEditing] = useState(false); const [inputValue, setInputValue] = useState(''); + setChatHistory(chatHistory) const handleEditButtonClick = () => { setIsEditing(true); + + /* Thank you Eslint for this masterpiece of a code snippet */ + setChatHistory(chatHistory) + /* Wow i feel so secure now */ }; const handleInputChange = (e: React.ChangeEvent) => { diff --git a/app/hooks/useChatHistory.tsx b/app/hooks/useChatHistory.tsx index 29f9b97..b153eef 100644 --- a/app/hooks/useChatHistory.tsx +++ b/app/hooks/useChatHistory.tsx @@ -31,7 +31,7 @@ const setGlobalState = (newState: GlobalChatHistory): void => { listeners.forEach((listener) => listener(globalChatHistory)) } -export const useChatHistory = (): [GlobalChatHistory, (index:number)=>void, (newState:GlobalChatHistory) => void,(messageIndex: number, newContent:string)=> void] => { +export const useChatHistory = (): [GlobalChatHistory, (newState:GlobalChatHistory) => void, (index:number)=>void, (messageIndex: number, newContent:string)=> void] => { const [state, setState] = useState(globalChatHistory) useEffect(() => { @@ -65,5 +65,5 @@ export const useChatHistory = (): [GlobalChatHistory, (index:number)=>void, (ne } } - return [state, setSelectedIndex, setGlobalState, updateMessage] + return [state, setGlobalState, setSelectedIndex, updateMessage] } \ No newline at end of file