import React from 'react'; import { defineMessages, useIntl } from 'react-intl'; import { useRouteMatch } from 'react-router-dom'; import { groupComposeModal } from 'pl-fe/actions/compose'; import { openModal } from 'pl-fe/actions/modals'; import { openSidebar } from 'pl-fe/actions/sidebar'; import ThumbNavigationLink from 'pl-fe/components/thumb-navigation-link'; import { useStatContext } from 'pl-fe/contexts/stat-context'; import { Entities } from 'pl-fe/entity-store/entities'; import { useAppDispatch, useAppSelector, useFeatures, useOwnAccount } from 'pl-fe/hooks'; import { isStandalone } from 'pl-fe/utils/state'; import { Icon } from './ui'; const messages = defineMessages({ home: { id: 'navigation.home', defaultMessage: 'Home' }, search: { id: 'navigation.search', defaultMessage: 'Search' }, notifications: { id: 'navigation.notifications', defaultMessage: 'Notifications' }, chats: { id: 'navigation.chats', defaultMessage: 'Chats' }, compose: { id: 'navigation.compose', defaultMessage: 'Compose' }, sidebar: { id: 'navigation.sidebar', defaultMessage: 'Open sidebar' }, }); const ThumbNavigation: React.FC = (): JSX.Element => { const intl = useIntl(); const dispatch = useAppDispatch(); const { account } = useOwnAccount(); const features = useFeatures(); const match = useRouteMatch<{ groupId: string }>('/groups/:groupId'); const { unreadChatsCount } = useStatContext(); const standalone = useAppSelector(isStandalone); const notificationCount = useAppSelector((state) => state.notifications.unread); const handleOpenSidebar = () => dispatch(openSidebar()); const handleOpenComposeModal = () => { if (match?.params.groupId) { dispatch((_, getState) => { const group = getState().entities[Entities.GROUPS]?.store[match.params.groupId]; if (group) dispatch(groupComposeModal(group)); }); } else { dispatch(openModal('COMPOSE')); } }; const composeButton = ( ); return (