Skip to content

Commit

Permalink
Local storage sync
Browse files Browse the repository at this point in the history
  • Loading branch information
dartpain committed Sep 12, 2023
1 parent ee0cbff commit 7f7856f
Show file tree
Hide file tree
Showing 7 changed files with 163 additions and 152 deletions.
276 changes: 139 additions & 137 deletions extensions/react-widget/dist/index.es.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion extensions/react-widget/dist/index.es.js.map

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions extensions/react-widget/dist/index.umd.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion extensions/react-widget/dist/index.umd.js.map

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions extensions/react-widget/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion extensions/react-widget/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "docsgpt",
"private": false,
"version": "0.2.0",
"version": "0.2.1",
"type": "module",
"main": "dist/index.umd.js",
"module": "dist/index.es.js",
Expand Down
10 changes: 9 additions & 1 deletion extensions/react-widget/src/components/DocsGPTWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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/'
Expand All @@ -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
Expand Down

0 comments on commit 7f7856f

Please sign in to comment.