import React from 'react'; import { FormattedMessage } from 'react-intl'; import ThumbNavigationLink from 'soapbox/components/thumb-navigation-link'; import { useStatContext } from 'soapbox/contexts/stat-context'; import { useAppSelector, useFeatures, useGroupsPath, useOwnAccount } from 'soapbox/hooks'; const ThumbNavigation: React.FC = (): JSX.Element => { const { account } = useOwnAccount(); const features = useFeatures(); const groupsPath = useGroupsPath(); const { unreadChatsCount } = useStatContext(); const notificationCount = useAppSelector((state) => state.notifications.unread); const dashboardCount = useAppSelector((state) => state.admin.openReports.count() + state.admin.awaitingApproval.count()); /** Conditionally render the supported messages link */ const renderMessagesLink = (): React.ReactNode => { if (features.chats) { return ( } to='/chats' exact count={unreadChatsCount} countMax={9} /> ); } if (features.directTimeline || features.conversations) { return ( } to='/messages' paths={['/messages', '/conversations']} /> ); } return null; }; return (
} to='/' exact /> {features.groups && ( } to={groupsPath} exact /> )} } to='/search' exact /> {account && ( } to='/notifications' exact count={notificationCount} /> )} {account && renderMessagesLink()} {(account && account.staff) && ( } to='/soapbox/admin' count={dashboardCount} /> )}
); }; export default ThumbNavigation;