@@ -48,34 +48,32 @@ interface ChannelSettingsProviderInterface {
4848 queries ?: ChannelSettingsQueries ;
4949 setChannelUpdateId ( uniqId : string ) : void ;
5050 forceUpdateUI ( ) : void ;
51- channel : GroupChannel ;
51+ channel : GroupChannel | null ;
5252 loading : boolean ;
5353 invalidChannel : boolean ;
5454}
5555
56- const ChannelSettingsContext = React . createContext < ChannelSettingsProviderInterface | null > ( undefined ) ;
57-
58- const ChannelSettingsProvider : React . FC < ChannelSettingsContextProps > = ( props : ChannelSettingsContextProps ) => {
59- const {
60- children,
61- className,
62- channelUrl,
63- onCloseClick,
64- onLeaveChannel,
65- onChannelModified,
66- overrideInviteUser,
67- onBeforeUpdateChannel,
68- queries,
69- } = props ;
70-
71- // fetch store from <SendbirdProvider />
72- const globalStore = useSendbirdStateContext ( ) ;
73- const { config, stores } = globalStore ;
56+ const ChannelSettingsContext = React . createContext < ChannelSettingsProviderInterface | null > ( null ) ;
57+
58+ const ChannelSettingsProvider = ( {
59+ children,
60+ className,
61+ channelUrl,
62+ onCloseClick,
63+ onLeaveChannel,
64+ onChannelModified,
65+ overrideInviteUser,
66+ onBeforeUpdateChannel,
67+ queries,
68+ renderUserProfile,
69+ disableUserProfile,
70+ } : ChannelSettingsContextProps ) => {
71+ const { config, stores } = useSendbirdStateContext ( ) ;
7472 const { sdkStore } = stores ;
7573 const { logger, onUserProfileMessage } = config ;
7674
7775 // hack to keep track of channel updates by triggering useEffect
78- const [ channelUpdateId , setChannelUpdateId ] = useState ( uuidv4 ( ) ) ;
76+ const [ channelUpdateId , setChannelUpdateId ] = useState ( ( ) => uuidv4 ( ) ) ;
7977 const forceUpdateUI = ( ) => setChannelUpdateId ( uuidv4 ( ) ) ;
8078
8179 const {
@@ -109,7 +107,7 @@ const ChannelSettingsProvider: React.FC<ChannelSettingsContextProps> = (props: C
109107
110108 useEffect ( ( ) => {
111109 refresh ( ) ;
112- } , [ channelUrl , sdkStore . initialized , channelUpdateId ] ) ;
110+ } , [ channelUrl , channelUpdateId ] ) ;
113111
114112 return (
115113 < ChannelSettingsContext . Provider
@@ -129,8 +127,8 @@ const ChannelSettingsProvider: React.FC<ChannelSettingsContextProps> = (props: C
129127 } }
130128 >
131129 < UserProfileProvider
132- renderUserProfile = { props ?. renderUserProfile }
133- disableUserProfile = { props ?. disableUserProfile ?? config ?. disableUserProfile }
130+ renderUserProfile = { renderUserProfile }
131+ disableUserProfile = { disableUserProfile ?? config ?. disableUserProfile }
134132 onUserProfileMessage = { onUserProfileMessage }
135133 >
136134 < div className = { `sendbird-channel-settings ${ className } ` } > { children } </ div >
@@ -139,7 +137,5 @@ const ChannelSettingsProvider: React.FC<ChannelSettingsContextProps> = (props: C
139137 ) ;
140138} ;
141139
142- export type UseChannelSettingsType = ( ) => ChannelSettingsProviderInterface ;
143- const useChannelSettingsContext : UseChannelSettingsType = ( ) => React . useContext ( ChannelSettingsContext ) ;
144-
140+ const useChannelSettingsContext = ( ) => React . useContext ( ChannelSettingsContext ) ;
145141export { ChannelSettingsProvider , useChannelSettingsContext } ;
0 commit comments