mirror of
https://github.com/arc53/DocsGPT.git
synced 2025-11-29 16:43:16 +00:00
Local storage sync
This commit is contained in:
@@ -109,7 +109,9 @@ function fetchAnswerStreaming({
|
||||
|
||||
export const DocsGPTWidget = ({ apiHost = 'https://gptcloud.arc53.com', selectDocs = 'default', apiKey = 'docsgpt-public'}) => {
|
||||
// processing states
|
||||
const [chatState, setChatState] = useState<ChatStates>(ChatStates.Init);
|
||||
const [chatState, setChatState] = useState<ChatStates>(
|
||||
() => localStorage.getItem('docsGPTChatState') as ChatStates || ChatStates.Init
|
||||
);
|
||||
const [answer, setAnswer] = useState<string>('');
|
||||
|
||||
//const selectDocs = 'local/1706.03762.pdf/'
|
||||
@@ -122,6 +124,12 @@ export const DocsGPTWidget = ({ apiHost = 'https://gptcloud.arc53.com', selectDo
|
||||
}
|
||||
}, [answer]);
|
||||
|
||||
useEffect(() => {
|
||||
if (chatState === ChatStates.Init || chatState === ChatStates.Minimized) {
|
||||
localStorage.setItem('docsGPTChatState', chatState);
|
||||
}
|
||||
}, [chatState]);
|
||||
|
||||
|
||||
|
||||
// submit handler
|
||||
|
||||
Reference in New Issue
Block a user