From 661b851c37c0a9e07f91d27fef9c4a48504f9ae1 Mon Sep 17 00:00:00 2001 From: bang9 Date: Fri, 6 Sep 2024 11:34:57 +0900 Subject: [PATCH] chore: rebase --- src/components/chat/index.tsx | 11 ++++++++++ src/components/widget/ProviderContainer.tsx | 23 ++------------------- 2 files changed, 13 insertions(+), 21 deletions(-) diff --git a/src/components/chat/index.tsx b/src/components/chat/index.tsx index 633fed733..17296b767 100644 --- a/src/components/chat/index.tsx +++ b/src/components/chat/index.tsx @@ -4,13 +4,16 @@ import useSendbirdStateContext from '@uikit/hooks/useSendbirdStateContext'; import { ChatContainer } from './context/ChatProvider'; import { ChatUI } from './ui'; +import { useConstantState } from '../../context/ConstantContext'; import { useWidgetSession, useWidgetSetting } from '../../context/WidgetSettingContext'; +import { useAssignGlobalFunction } from '../../hooks/useAssignGlobalFunction'; import useAutoDismissMobileKeyboardHandler from '../../hooks/useAutoDismissMobileKeyboardHandler'; import { useResetHistoryOnConnected } from '../../hooks/useResetHistoryOnConnected'; import { useWidgetInactivityTimeout } from '../../hooks/useWidgetInactivityTimeout'; const Chat = ({ fullscreen = false }: { fullscreen?: boolean }) => { const { stores } = useSendbirdStateContext(); + const { locale } = useConstantState(); const widgetSetting = useWidgetSetting(); const widgetSession = useWidgetSession(); @@ -29,6 +32,13 @@ const Chat = ({ fullscreen = false }: { fullscreen?: boolean }) => { stores.sdkStore.initialized, ]); + // Set locale for chatbot + useEffect(() => { + if (locale && stores.sdkStore.initialized && stores.sdkStore.sdk) { + stores.sdkStore.sdk.setLocaleForChatbot(locale); + } + }, [locale, stores.sdkStore.initialized, stores.sdkStore.sdk]); + return ( { }; const HeadlessForHooks = ({ fullscreen }: { fullscreen: boolean }) => { + useAssignGlobalFunction(); useResetHistoryOnConnected(); useWidgetInactivityTimeout(fullscreen); useAutoDismissMobileKeyboardHandler(); diff --git a/src/components/widget/ProviderContainer.tsx b/src/components/widget/ProviderContainer.tsx index b0689bb7e..e339f3115 100644 --- a/src/components/widget/ProviderContainer.tsx +++ b/src/components/widget/ProviderContainer.tsx @@ -1,8 +1,6 @@ import { SendbirdErrorCode } from '@sendbird/chat'; -import React, { PropsWithChildren, useEffect, useMemo } from 'react'; +import React, { useMemo } from 'react'; import { StyleSheetManager, ThemeProvider } from 'styled-components'; - -import { useSendbirdStateContext } from '@uikit/index'; import SendbirdProvider from '@uikit/lib/Sendbird'; import { ChatAiWidgetProps } from './ChatAiWidget'; @@ -10,7 +8,6 @@ import { generateCSSVariables } from '../../colors'; import { ConstantStateProvider, useConstantState } from '../../context/ConstantContext'; import { useWidgetSession, useWidgetSetting, WidgetSettingProvider } from '../../context/WidgetSettingContext'; import { useWidgetState, WidgetStateProvider } from '../../context/WidgetStateContext'; -import { useAssignGlobalFunction } from '../../hooks/useAssignGlobalFunction'; import { useStyledComponentsTarget } from '../../hooks/useStyledComponentsTarget'; import { getTheme } from '../../theme'; import { isDashboardPreview } from '../../utils'; @@ -136,25 +133,9 @@ export default function ProviderContainer(props: ProviderContainerProps) { - - {props.children} - + {props.children} ); } - -const HeadlessComponent = ({ children }: PropsWithChildren) => { - useAssignGlobalFunction(); - const { locale } = useConstantState(); - const { stores } = useSendbirdStateContext(); - - useEffect(() => { - if (locale && stores.sdkStore.initialized && stores.sdkStore.sdk) { - stores.sdkStore.sdk.setLocaleForChatbot(locale); - } - }, [locale, stores.sdkStore.initialized, stores.sdkStore.sdk]); - - return <>{children}; -};