@@ -155,6 +155,10 @@ const Chat = ({ type = ChatType.Browse }: Props) => {
155155 processTemplateResponse ( )
156156 } , [ location ] )
157157
158+ useEffect ( ( ) => {
159+ appStateContext ?. dispatch ( { type : 'GENERATE_ISLODING' , payload : appStateContext ?. state . isGenerating } )
160+ } , [ isLoading ] )
161+
158162 useEffect ( ( ) => {
159163 if (
160164 appStateContext ?. state . isCosmosDBAvailable ?. status !== CosmosDBStatus . Working &&
@@ -279,6 +283,7 @@ const Chat = ({ type = ChatType.Browse }: Props) => {
279283
280284 const makeApiRequestWithoutCosmosDB = async ( question : string , conversationId ?: string ) => {
281285 setIsLoading ( true )
286+ appStateContext ?. dispatch ( { type : 'GENERATE_ISLODING' , payload : true } )
282287 setShowLoadingMessage ( true )
283288 const abortController = new AbortController ( )
284289 abortFuncs . current . unshift ( abortController )
@@ -395,6 +400,7 @@ const Chat = ({ type = ChatType.Browse }: Props) => {
395400 } finally {
396401 setIsLoading ( false )
397402 setShowLoadingMessage ( false )
403+ appStateContext ?. dispatch ( { type : 'GENERATE_ISLODING' , payload : false } )
398404 abortFuncs . current = abortFuncs . current . filter ( a => a !== abortController )
399405 setProcessMessages ( messageStatus . Done )
400406 }
@@ -404,6 +410,7 @@ const Chat = ({ type = ChatType.Browse }: Props) => {
404410
405411 const makeApiRequestWithCosmosDB = async ( question : string , conversationId ?: string ) => {
406412 setIsLoading ( true )
413+ appStateContext ?. dispatch ( { type : 'GENERATE_ISLODING' , payload : true } )
407414 setShowLoadingMessage ( true )
408415 const abortController = new AbortController ( )
409416 abortFuncs . current . unshift ( abortController )
@@ -423,6 +430,7 @@ const Chat = ({ type = ChatType.Browse }: Props) => {
423430 if ( ! conversation ) {
424431 console . error ( 'Conversation not found.' )
425432 setIsLoading ( false )
433+ appStateContext ?. dispatch ( { type : 'GENERATE_ISLODING' , payload : false } )
426434 setShowLoadingMessage ( false )
427435 abortFuncs . current = abortFuncs . current . filter ( a => a !== abortController )
428436 return
@@ -468,6 +476,7 @@ const Chat = ({ type = ChatType.Browse }: Props) => {
468476 } else {
469477 setMessages ( [ ...messages , userMessage , errorChatMsg ] )
470478 setIsLoading ( false )
479+ appStateContext ?. dispatch ( { type : 'GENERATE_ISLODING' , payload : false } )
471480 setShowLoadingMessage ( false )
472481 abortFuncs . current = abortFuncs . current . filter ( a => a !== abortController )
473482 return
@@ -529,6 +538,7 @@ const Chat = ({ type = ChatType.Browse }: Props) => {
529538 if ( ! resultConversation ) {
530539 console . error ( 'Conversation not found.' )
531540 setIsLoading ( false )
541+ appStateContext ?. dispatch ( { type : 'GENERATE_ISLODING' , payload : false } )
532542 setShowLoadingMessage ( false )
533543 abortFuncs . current = abortFuncs . current . filter ( a => a !== abortController )
534544 return
@@ -549,6 +559,7 @@ const Chat = ({ type = ChatType.Browse }: Props) => {
549559 }
550560 if ( ! resultConversation ) {
551561 setIsLoading ( false )
562+ appStateContext ?. dispatch ( { type : 'GENERATE_ISLODING' , payload : false } )
552563 setShowLoadingMessage ( false )
553564 abortFuncs . current = abortFuncs . current . filter ( a => a !== abortController )
554565 return
@@ -582,6 +593,7 @@ const Chat = ({ type = ChatType.Browse }: Props) => {
582593 if ( ! resultConversation ) {
583594 console . error ( 'Conversation not found.' )
584595 setIsLoading ( false )
596+ appStateContext ?. dispatch ( { type : 'GENERATE_ISLODING' , payload : false } )
585597 setShowLoadingMessage ( false )
586598 abortFuncs . current = abortFuncs . current . filter ( a => a !== abortController )
587599 return
@@ -598,6 +610,7 @@ const Chat = ({ type = ChatType.Browse }: Props) => {
598610 }
599611 setMessages ( [ ...messages , userMessage , errorChatMsg ] )
600612 setIsLoading ( false )
613+ appStateContext ?. dispatch ( { type : 'GENERATE_ISLODING' , payload : false } )
601614 setShowLoadingMessage ( false )
602615 abortFuncs . current = abortFuncs . current . filter ( a => a !== abortController )
603616 return
@@ -612,6 +625,7 @@ const Chat = ({ type = ChatType.Browse }: Props) => {
612625 }
613626 if ( ! resultConversation ) {
614627 setIsLoading ( false )
628+ appStateContext ?. dispatch ( { type : 'GENERATE_ISLODING' , payload : false } )
615629 setShowLoadingMessage ( false )
616630 abortFuncs . current = abortFuncs . current . filter ( a => a !== abortController )
617631 return
@@ -747,6 +761,7 @@ const Chat = ({ type = ChatType.Browse }: Props) => {
747761 abortFuncs . current . forEach ( a => a . abort ( ) )
748762 setShowLoadingMessage ( false )
749763 setIsLoading ( false )
764+ appStateContext ?. dispatch ( { type : 'GENERATE_ISLODING' , payload : false } )
750765 }
751766
752767 useEffect ( ( ) => {
0 commit comments