import { useDispatch, useSelector } from 'react-redux'; import AppNavbar from '../navigation/app-navbar'; import Sidebar from '../navigation/sidebar/sidebar'; import { Redirect, useParams } from 'react-router-dom'; import { actions as uiActions } from '../../store/ui'; import TextBasedChannel from '../channel/text-based-channel'; import MemberList from '../user/member-list'; import { getGuild, getGuildChannels } from '../../store/guilds'; import { useEffect } from 'react'; import PageWrapper from './page-wrapper'; import { getChannel } from '../../store/channels'; const GuildPage: React.FunctionComponent = () => { const { channelId, guildId }: any = useParams(); const dispatch = useDispatch(); const ui = useSelector((s: Store.AppState) => s.ui); const guild = useSelector(getGuild(guildId)); const channel = useSelector(getChannel(channelId)); const textChannels = useSelector(getGuildChannels(guildId)).filter(c => c.type === 'TEXT'); useEffect(() => { dispatch(uiActions.pageSwitched({ channel, guild })); }, [guild, channel]); if (!guild) return ; else if (textChannels.length && !channelId) { const systemChannel = textChannels[0]; return ; } return (ui.activeGuild) ? ( {(channel) ?
{ui.activeChannel && { 'TEXT': , 'DM': , 'VOICE':
Add something cool here for voice channels?
, }[channel.type]}
:
} ) : null; } export default GuildPage;