// @flow import React, { useState, useEffect } from 'react'; import compose from 'recompose/compose'; import { connect } from 'react-redux'; import type { Dispatch } from 'redux'; import { withRouter, type Location } from 'react-router-dom'; import type { UserInfoType } from 'shared/graphql/fragments/user/userInfo'; import type { CommunityInfoType } from 'shared/graphql/fragments/community/communityInfo'; import generateMetaInfo from 'shared/generate-meta-info'; import { withCurrentUser } from 'src/components/withCurrentUser'; import Head from 'src/components/head'; import { CommunityAvatar } from 'src/components/avatar'; import { setTitlebarProps } from 'src/actions/titlebar'; import { CommunityFeeds } from '../components/communityFeeds'; import { ViewGrid, SecondaryPrimaryColumnGrid, PrimaryColumn, SecondaryColumn, } from 'src/components/layout'; import Sidebar from 'src/components/communitySidebar'; import { FullScreenRedirectView } from 'src/views/viewHelpers/fullScreenRedirect'; type Props = { community: CommunityInfoType, currentUser: ?UserInfoType, dispatch: Dispatch, location: Location, }; const Component = (props: Props) => { const { community, dispatch, location } = props; const [metaInfo, setMetaInfo] = useState( generateMetaInfo({ type: 'community', data: { name: community.name, description: community.description, }, }) ); useEffect(() => { setMetaInfo( generateMetaInfo({ type: 'community', data: { name: `${community.name} community`, description: community.description, }, }) ); dispatch( setTitlebarProps({ title: community.name, titleIcon: ( ), }) ); }, [community.id]); useEffect(() => { dispatch( setTitlebarProps({ title: community.name, titleIcon: ( ), }) ); }, [location]); const { title, description } = metaInfo; if (community.redirect && community.website) { return ; } return ( {community.redirect && community.noindex && ( )} ); }; export const SignedIn = compose( withCurrentUser, withRouter, connect() )(Component);