@@ -11,11 +11,10 @@ import {
1111
1212const useFetchChatData = ( showRoles ) => {
1313 const { RCInstance, ECOptions } = useContext ( RCContext ) ;
14- const setMemberRoles = useMemberStore ( ( state ) => state . setMemberRoles ) ;
15- const isChannelPrivate = useChannelStore ( ( state ) => state . isChannelPrivate ) ;
1614 const setMessages = useMessageStore ( ( state ) => state . setMessages ) ;
1715 const setMessagesOffset = useMessageStore ( ( state ) => state . setMessagesOffset ) ;
1816 const setAdmins = useMemberStore ( ( state ) => state . setAdmins ) ;
17+ const setMemberRoles = useMemberStore ( ( state ) => state . setMemberRoles ) ;
1918 const permissionsRef = useRef ( null ) ;
2019 const setStarredMessages = useStarredMessageStore (
2120 ( state ) => state . setStarredMessages
@@ -127,6 +126,22 @@ const useFetchChatData = (showRoles) => {
127126 return ;
128127 }
129128
129+ let channelIsPrivate = false ;
130+ if ( ! anonymousMode ) {
131+ const { channelInfo, setChannelInfo, setIsChannelPrivate } =
132+ useChannelStore . getState ( ) ;
133+ if ( channelInfo ?. _id ) {
134+ channelIsPrivate = channelInfo . t === 'p' ;
135+ } else {
136+ const res = await RCInstance . channelInfo ( ) ;
137+ if ( res ?. success ) {
138+ setChannelInfo ( res . room ) ;
139+ channelIsPrivate = res . room . t === 'p' ;
140+ if ( channelIsPrivate ) setIsChannelPrivate ( true ) ;
141+ }
142+ }
143+ }
144+
130145 const { messages, count } = await RCInstance . getMessages (
131146 anonymousMode ,
132147 ECOptions ?. enableThreads
@@ -138,7 +153,7 @@ const useFetchChatData = (showRoles) => {
138153 } ,
139154 }
140155 : undefined ,
141- anonymousMode ? false : isChannelPrivate
156+ channelIsPrivate
142157 ) ;
143158
144159 if ( messages ) {
@@ -151,7 +166,7 @@ const useFetchChatData = (showRoles) => {
151166 }
152167
153168 if ( showRoles ) {
154- const { roles } = await RCInstance . getChannelRoles ( isChannelPrivate ) ;
169+ const { roles } = await RCInstance . getChannelRoles ( channelIsPrivate ) ;
155170 const fetchedRoles = await RCInstance . getUserRoles ( ) ;
156171 const fetchedAdmins = fetchedRoles ?. result ;
157172
@@ -176,7 +191,6 @@ const useFetchChatData = (showRoles) => {
176191 isUserAuthenticated ,
177192 RCInstance ,
178193 ECOptions ?. enableThreads ,
179- isChannelPrivate ,
180194 showRoles ,
181195 setMessages ,
182196 setAdmins ,
0 commit comments