From 225ed914de5622ba7dbf3ed5250d9ce3054d2f47 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 | 22 ++------------------- 2 files changed, 13 insertions(+), 20 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..ffdc7fd88 100644 --- a/src/components/widget/ProviderContainer.tsx +++ b/src/components/widget/ProviderContainer.tsx @@ -1,8 +1,7 @@ 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 +9,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 +134,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}; -};