import { createContext, Dispatch, SetStateAction } from "react"

export const ScreenInfoContext = createContext<{
  isRightPanelVisible: boolean
  // currentRoom: RoomType | null
  // setCurrentRoom: Dispatch<SetStateAction<RoomType | null>>
  // tabBarVisible: boolean
  // setTabBarVisible: Dispatch<SetStateAction<boolean>>
  communityId: string | null
  screenInfo: {
    type: "community" | "message" | "contact"
    roomId: string | null
  }
  setCommunityId: Dispatch<SetStateAction<string | null>>
  setScreenInfo: Dispatch<
    SetStateAction<{
      type: "community" | "message" | "contact"
      roomId: string | null
    }>
  >
  setRightPanelVisible: (isVisible: boolean) => void
}>({
  isRightPanelVisible: false,
  // currentRoom: null,
  // setCurrentRoom: () => {},
  // tabBarVisible: false,
  // setTabBarVisible: () => {},
  communityId: "",
  screenInfo: {
    type: "message",
    roomId: null,
  },
  setCommunityId() {},
  setScreenInfo() {},
  setRightPanelVisible() {},
})
this is my screen info component
in the below my community search component
import { CommunityProfileType } from "@openchat/types"
import React, { useContext, useEffect, useState } from "react"
import { FlatList, useWindowDimensions, View } from "react-native"
import { StyledText } from "../../../ui-components/styled-text/styled-text"
import { AppController } from "../../../app/app.globals"
import { NavigationRef } from "../../../navigation/navigation.hooks"
import { Input } from "../../../ui-components/input/input"
import { StickyHeader } from "../../../ui-components/sticky-header/sticky-header.component"
import { CommunitySearchItem } from "./community-search-item.component"
import { useStyles } from "./community-search.style"
import { ScreenInfoContext } from "../../../context/screen-info/screen-info.context"
import { AppConfig } from "../../../app/app.config"

export const CommunitySearch = () => {
 // ---------------------------------------------------------------------------
 // variables
 // ---------------------------------------------------------------------------
 const { height, width } = useWindowDimensions()
 const styles = useStyles()
 const [isLoading, setLoading] = useState(false)
 const [communities, setCommunities] = useState<CommunityProfileType[]>([])
 const [keyword, setKeyword] = useState("")
 const [skip, setSkip] = useState(0)
 const { setScreenInfo, setCommunityId } = useContext(ScreenInfoContext)

 // ---------------------------------------------------------------------------
 // effects
 // ---------------------------------------------------------------------------

 useEffect(() => {
  loadCommunities(keyword)
 }, [keyword])

 // ---------------------------------------------------------------------------
 // functions
 // ---------------------------------------------------------------------------

 async function loadCommunities(newKeyword: string) {
  if (isLoading) return
  setLoading(true)

  // todo: why do we allow selection of multiple registries, but search in a single one? fix it
  const resultSearch = await AppController.communityProfile.search(newKeyword)

  setCommunities(resultSearch)
  setLoading(false)
 }

 async function join(communityProfile: CommunityProfileType) {
  await AppController.accountCommunity.save(communityProfile)
  setCommunityId(communityProfile.id)
  setScreenInfo({ type: "community", roomId: null })
  NavigationRef.navigate(AppConfig.isTablet ? "DashboardScreen" : "Dashboard")
 }

 let numColumns =
  AppConfig.isTablet && height < width ? 3 : AppConfig.isTablet ? 2 : 1

 // ---------------------------------------------------------------------------
 return (
  <View style={styles.wrapper}>
   <StickyHeader
    goBack={true}
    isScrollView={AppConfig.isTablet ? true : false}
    // isScrollEnabled={AppConfig.isTablet ? false : true}
    background="bubbles"
    type="full-screen"
    title="Find Community"
    onPress={() => NavigationRef.goBack()}
    header={
     <StyledText style={[styles.title]}>
      Find Your Community on Open Chat
     </StyledText>
    }
   >
    {/* --------------------------------------------------------------------------- */}
    {/* BACK ICON */}
    {/* --------------------------------------------------------------------------- */}
    <View style={styles.container}>
     <View style={styles.header}>
      <StyledText style={[styles.description]}>
       Add up to 50 custom stickers that anyone can use in this server.
       Stickers names must be at least 2 characters long and can only
       contain alphanumeric characters and underscores. Sticker must be
       under 265 kb in size.
      </StyledText>

      <Input
       mode="secondary"
       wrapperStyle={{
        width: "100%",
       }}
       placeholder="Search community"
       showIcon={true}
       type={keyword ? "clear" : "search"}
       value={keyword}
       onIconPress={() => setKeyword("")}
       onChangeText={(value) => {
        if (value === keyword) return
        setSkip(0)
        setKeyword(value)
       }}
      />
     </View>

     {/* --------------------------------------------------------------------------- */}
     {/* CONTENT */}
     {/* --------------------------------------------------------------------------- */}

     {communities.length === 0 ? (
      <View style={styles.noResultContainer}>
       <StyledText style={styles.noResultText}>
        No search result
       </StyledText>
      </View>
     ) : (
      <View style={styles.list}>
       <FlatList
        key={numColumns}
        contentContainerStyle={{
         alignItems: AppConfig.isTablet ? "center" : "stretch",
        }}
        numColumns={numColumns}
        data={communities}
        renderItem={({ item }) => (
         <CommunitySearchItem
          community={item}
          onPress={() => join(item)}
          key={item.id}
         />
        )}
        keyExtractor={(item) => item.id}
       />
      </View>
     )}
    </View>
   </StickyHeader>
  </View>
 )
}
I get setScreenInfo, setCommunityId from ScreenInfoContext component. When I press join first it is joining then takes me to this community that I joined. The issue when community is private it is joining me to this private community but content not showing. If it is public it's working as expected. How to fix it ?