Skip to content

Commit

Permalink
Fix thinking
Browse files Browse the repository at this point in the history
  • Loading branch information
arcangelini committed Oct 16, 2024
1 parent bec817a commit ec4f57e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/odie-client/src/context/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ const useOdieAssistantContext = () => useContext( OdieAssistantContext );
export const odieClientId = Math.random().toString( 36 ).substring( 2, 15 );

type OdieAssistantProviderProps = {
shouldUseHelpCenterExperience?: boolean;
botName?: string;
botNameSlug?: OdieAllowedBots;
odieInitialPromptText?: string;
Expand All @@ -133,6 +134,7 @@ type OdieAssistantProviderProps = {
} & PropsWithChildren;
// Create a provider component for the context
const OdieAssistantProvider: FC< OdieAssistantProviderProps > = ( {
shouldUseHelpCenterExperience,
botName = 'Wapuu assistant',
initialUserMessage,
isLoadingEnvironment = false,
Expand Down Expand Up @@ -248,7 +250,13 @@ const OdieAssistantProvider: FC< OdieAssistantProviderProps > = ( {
);

useEffect( () => {
if ( existingChat.chat_id ) {
if ( ! shouldUseHelpCenterExperience && existingChat.chat_id ) {
setChat( existingChat );
}
}, [ existingChat, existingChat.chat_id ] );

useEffect( () => {
if ( shouldUseHelpCenterExperience && existingChat.chat_id ) {
setIsLoading( true );

if ( isChatLoaded ) {
Expand All @@ -274,7 +282,7 @@ const OdieAssistantProvider: FC< OdieAssistantProviderProps > = ( {
}, [ existingChat, isChatLoaded, getConversationByChatId ] );

useEffect( () => {
if ( supportProvider === 'zendesk' && isChatLoaded ) {
if ( shouldUseHelpCenterExperience && supportProvider === 'zendesk' && isChatLoaded ) {
zendeskMessageListener( existingChat.chat_id, ( message ) => {
addMessage( { content: message.text, role: 'business', type: 'message' } );
} );
Expand Down

0 comments on commit ec4f57e

Please sign in to comment.