1- import React , { PropsWithChildren , useEffect , useState } from 'react' ;
1+ import React , { PropsWithChildren , useEffect , useMemo , useState } from 'react' ;
22import { Image , Platform } from 'react-native' ;
33
44import { Channel , OfflineDBState } from 'stream-chat' ;
@@ -11,8 +11,7 @@ import { useMutedUsers } from './hooks/useMutedUsers';
1111import { ChannelsStateProvider } from '../../contexts/channelsStateContext/ChannelsStateContext' ;
1212import { ChatContextValue , ChatProvider } from '../../contexts/chatContext/ChatContext' ;
1313import { useDebugContext } from '../../contexts/debugContext/DebugContext' ;
14- import { useOverlayContext } from '../../contexts/overlayContext/OverlayContext' ;
15- import { DeepPartial , ThemeProvider } from '../../contexts/themeContext/ThemeContext' ;
14+ import { DeepPartial , ThemeProvider , useTheme } from '../../contexts/themeContext/ThemeContext' ;
1615import type { Theme } from '../../contexts/themeContext/utils/theme' ;
1716import {
1817 DEFAULT_USER_LANGUAGE ,
@@ -156,6 +155,11 @@ const ChatWithContext = (props: PropsWithChildren<ChatProps>) => {
156155 // Setup translators
157156 const translators = useStreami18n ( i18nInstance ) ;
158157
158+ const translationContextValue = useMemo (
159+ ( ) => ( { ...translators , userLanguage : client . user ?. language || DEFAULT_USER_LANGUAGE } ) ,
160+ [ client . user ?. language , translators ] ,
161+ ) ;
162+
159163 /**
160164 * Setup connection event listeners
161165 */
@@ -262,9 +266,7 @@ const ChatWithContext = (props: PropsWithChildren<ChatProps>) => {
262266
263267 return (
264268 < ChatProvider value = { chatContext } >
265- < TranslationProvider
266- value = { { ...translators , userLanguage : client . user ?. language || DEFAULT_USER_LANGUAGE } }
267- >
269+ < TranslationProvider value = { translationContextValue } >
268270 < ThemeProvider style = { style } >
269271 < ChannelsStateProvider > { children } </ ChannelsStateProvider >
270272 </ ThemeProvider >
@@ -286,7 +288,7 @@ const ChatWithContext = (props: PropsWithChildren<ChatProps>) => {
286288 * - setActiveChannel - function to set the currently active channel
287289 */
288290export const Chat = ( props : PropsWithChildren < ChatProps > ) => {
289- const { style } = useOverlayContext ( ) ;
291+ const { theme } = useTheme ( ) ;
290292
291- return < ChatWithContext { ... { style } } { ...props } /> ;
293+ return < ChatWithContext style = { theme as DeepPartial < Theme > } { ...props } /> ;
292294} ;
0 commit comments