2022-03-30 08:37:30 -07:00
|
|
|
import React from 'react';
|
|
|
|
import { FormattedMessage } from 'react-intl';
|
2024-08-14 07:52:11 -07:00
|
|
|
import { useRouteMatch } from 'react-router-dom';
|
2022-03-30 08:37:30 -07:00
|
|
|
|
2024-08-14 07:52:11 -07:00
|
|
|
import { groupComposeModal } from 'soapbox/actions/compose';
|
|
|
|
import { openModal } from 'soapbox/actions/modals';
|
2024-06-28 14:42:44 -07:00
|
|
|
import { openSidebar } from 'soapbox/actions/sidebar';
|
2022-11-15 08:00:49 -08:00
|
|
|
import ThumbNavigationLink from 'soapbox/components/thumb-navigation-link';
|
2022-09-27 13:05:19 -07:00
|
|
|
import { useStatContext } from 'soapbox/contexts/stat-context';
|
2024-08-14 07:52:11 -07:00
|
|
|
import { Entities } from 'soapbox/entity-store/entities';
|
2024-06-28 14:42:44 -07:00
|
|
|
import { useAppDispatch, useAppSelector, useFeatures, useOwnAccount } from 'soapbox/hooks';
|
|
|
|
|
|
|
|
import { Icon } from './ui';
|
2022-03-30 08:37:30 -07:00
|
|
|
|
|
|
|
const ThumbNavigation: React.FC = (): JSX.Element => {
|
2024-06-28 14:42:44 -07:00
|
|
|
const dispatch = useAppDispatch();
|
2023-06-25 10:35:09 -07:00
|
|
|
const { account } = useOwnAccount();
|
2023-06-14 05:05:25 -07:00
|
|
|
const features = useFeatures();
|
|
|
|
|
2024-08-14 07:52:11 -07:00
|
|
|
const match = useRouteMatch<{ groupId: string }>('/groups/:groupId');
|
|
|
|
|
2022-09-27 13:05:19 -07:00
|
|
|
const { unreadChatsCount } = useStatContext();
|
|
|
|
|
2022-03-30 08:37:30 -07:00
|
|
|
const notificationCount = useAppSelector((state) => state.notifications.unread);
|
|
|
|
|
2024-08-14 07:52:11 -07:00
|
|
|
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'));
|
|
|
|
}
|
|
|
|
};
|
2024-06-28 14:42:44 -07:00
|
|
|
|
2022-04-30 09:45:58 -07:00
|
|
|
/** Conditionally render the supported messages link */
|
|
|
|
const renderMessagesLink = (): React.ReactNode => {
|
|
|
|
if (features.chats) {
|
|
|
|
return (
|
|
|
|
<ThumbNavigationLink
|
2024-04-03 04:28:30 -07:00
|
|
|
src={require('@tabler/icons/outline/messages.svg')}
|
2022-12-06 13:16:36 -08:00
|
|
|
text={<FormattedMessage id='navigation.chats' defaultMessage='Chats' />}
|
2022-04-30 09:45:58 -07:00
|
|
|
to='/chats'
|
|
|
|
exact
|
2022-09-27 13:05:19 -07:00
|
|
|
count={unreadChatsCount}
|
2022-11-03 09:48:17 -07:00
|
|
|
countMax={9}
|
2022-04-30 09:45:58 -07:00
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2024-08-04 07:09:52 -07:00
|
|
|
if (features.conversations) {
|
2022-04-30 09:45:58 -07:00
|
|
|
return (
|
|
|
|
<ThumbNavigationLink
|
2024-04-03 04:28:30 -07:00
|
|
|
src={require('@tabler/icons/outline/mail.svg')}
|
|
|
|
activeSrc={require('@tabler/icons/filled/mail.svg')}
|
2022-04-30 09:45:58 -07:00
|
|
|
text={<FormattedMessage id='navigation.direct_messages' defaultMessage='Messages' />}
|
2024-08-11 01:48:58 -07:00
|
|
|
to='/conversations'
|
2022-04-30 09:45:58 -07:00
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
};
|
|
|
|
|
2022-03-30 08:37:30 -07:00
|
|
|
return (
|
2024-05-01 10:19:21 -07:00
|
|
|
<div className='fixed inset-x-0 bottom-0 z-50 flex w-full overflow-x-auto border-t border-solid border-gray-200 bg-white/90 shadow-2xl backdrop-blur-md black:bg-black/80 lg:hidden dark:border-gray-800 dark:bg-primary-900/90'>
|
2024-08-14 07:52:11 -07:00
|
|
|
<button className='flex flex-1 flex-col items-center px-2 py-4 text-lg text-gray-600' onClick={handleOpenSidebar}>
|
2024-06-28 14:42:44 -07:00
|
|
|
<Icon
|
|
|
|
src={require('@tabler/icons/outline/menu-2.svg')}
|
|
|
|
className='h-5 w-5 text-gray-600 black:text-white'
|
|
|
|
/>
|
|
|
|
</button>
|
|
|
|
|
2022-03-30 08:37:30 -07:00
|
|
|
<ThumbNavigationLink
|
2024-04-03 04:28:30 -07:00
|
|
|
src={require('@tabler/icons/outline/home.svg')}
|
|
|
|
activeSrc={require('@tabler/icons/filled/home.svg')}
|
2022-03-30 08:37:30 -07:00
|
|
|
text={<FormattedMessage id='navigation.home' defaultMessage='Home' />}
|
|
|
|
to='/'
|
|
|
|
exact
|
|
|
|
/>
|
|
|
|
|
2023-06-14 05:05:25 -07:00
|
|
|
{features.groups && (
|
|
|
|
<ThumbNavigationLink
|
2024-04-03 04:28:30 -07:00
|
|
|
src={require('@tabler/icons/outline/circles.svg')}
|
|
|
|
activeSrc={require('@tabler/icons/filled/circles.svg')}
|
2023-06-14 05:05:25 -07:00
|
|
|
text={<FormattedMessage id='tabs_bar.groups' defaultMessage='Groups' />}
|
2024-04-28 05:50:23 -07:00
|
|
|
to='/groups'
|
2023-06-14 05:05:25 -07:00
|
|
|
exact
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
|
2022-03-30 08:37:30 -07:00
|
|
|
<ThumbNavigationLink
|
2024-04-03 04:28:30 -07:00
|
|
|
src={require('@tabler/icons/outline/search.svg')}
|
2022-03-30 08:37:30 -07:00
|
|
|
text={<FormattedMessage id='navigation.search' defaultMessage='Search' />}
|
|
|
|
to='/search'
|
|
|
|
exact
|
|
|
|
/>
|
|
|
|
|
|
|
|
{account && (
|
|
|
|
<ThumbNavigationLink
|
2024-04-03 04:28:30 -07:00
|
|
|
src={require('@tabler/icons/outline/bell.svg')}
|
|
|
|
activeSrc={require('@tabler/icons/filled/bell.svg')}
|
2023-10-11 13:15:50 -07:00
|
|
|
text={<FormattedMessage id='navigation.notifications' defaultMessage='Notifications' />}
|
2022-03-30 08:37:30 -07:00
|
|
|
to='/notifications'
|
|
|
|
exact
|
|
|
|
count={notificationCount}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
|
2022-04-30 09:45:58 -07:00
|
|
|
{account && renderMessagesLink()}
|
2022-03-30 08:37:30 -07:00
|
|
|
|
2024-08-14 07:52:11 -07:00
|
|
|
{account && (
|
|
|
|
<button className='flex flex-1 flex-col items-center px-1.5 py-3.5 text-lg text-gray-600' onClick={handleOpenComposeModal}>
|
|
|
|
<Icon
|
|
|
|
src={require('@tabler/icons/outline/square-rounded-plus.svg')}
|
|
|
|
className='h-6 w-6 text-gray-600 black:text-white'
|
|
|
|
/>
|
|
|
|
</button>
|
2022-04-13 16:15:23 -07:00
|
|
|
)}
|
2022-03-30 08:37:30 -07:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2024-05-13 10:00:42 -07:00
|
|
|
export { ThumbNavigation as default };
|