Skip to content
Permalink
Browse files
Update Topic.tsx
  • Loading branch information
productlabs committed Nov 14, 2022
1 parent d4a75e7 commit f6b78a1b0fc19231021f5166fde6e1a0537319b6
Showing 1 changed file with 4 additions and 2 deletions.
@@ -12,6 +12,7 @@ const Widget = () => {

const { state, setHeader, setSize } = hasMounted && useTextKitWidget();

const [previousState, setPreviousState] = useState<any>(false);
const [headerReplaced, setHeaderReplaced] = useState<boolean>(false);
const [conversation, setConversation] = useState<any>(false);
const [loading, setLoading] = useState<boolean>(false);
@@ -36,7 +37,7 @@ const Widget = () => {
}

useEffect(() => {
if (state && state?.context) {
if (state && state?.context && state !== previousState) {
if (!conversation) { setLoading(true) }
fetch(`/api/context?conversation=${state?.context?.conversationId}`,{
method: 'get',
@@ -46,7 +47,8 @@ const Widget = () => {
})
.then( async (res) => {
const result = await res.json()
setConversation(result.context);
setConversation(result.context);
setPreviousState(state);
setLoading(false);
})
}

0 comments on commit f6b78a1

Please sign in to comment.