2022-03-21 11:09:01 -07:00
|
|
|
import { Map as ImmutableMap } from 'immutable';
|
|
|
|
import React from 'react';
|
|
|
|
import { FormattedMessage } from 'react-intl';
|
|
|
|
|
|
|
|
import { getSettings } from 'soapbox/actions/settings';
|
|
|
|
import ComposeButton from 'soapbox/features/ui/components/compose-button';
|
|
|
|
import { useAppSelector } from 'soapbox/hooks';
|
|
|
|
import { getBaseURL } from 'soapbox/utils/accounts';
|
|
|
|
import { getFeatures } from 'soapbox/utils/features';
|
|
|
|
|
|
|
|
import SidebarNavigationLink from './sidebar-navigation-link';
|
|
|
|
|
|
|
|
const SidebarNavigation = () => {
|
|
|
|
const me = useAppSelector((state) => state.me);
|
|
|
|
const instance = useAppSelector((state) => state.instance);
|
|
|
|
const settings = useAppSelector((state) => getSettings(state));
|
|
|
|
const account = useAppSelector((state) => state.accounts.get(me));
|
|
|
|
const notificationCount = useAppSelector((state) => state.notifications.get('unread'));
|
|
|
|
const chatsCount = useAppSelector((state) => state.chats.get('items').reduce((acc: any, curr: any) => acc + Math.min(curr.get('unread', 0), 1), 0));
|
|
|
|
|
|
|
|
const baseURL = getBaseURL(ImmutableMap(account));
|
|
|
|
const features = getFeatures(instance);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<div className='flex flex-col space-y-2'>
|
|
|
|
<SidebarNavigationLink
|
|
|
|
to='/'
|
|
|
|
icon={require('icons/feed.svg')}
|
2022-04-12 18:10:47 -07:00
|
|
|
text={<FormattedMessage id='tabs_bar.home' defaultMessage='Home' />}
|
2022-03-21 11:09:01 -07:00
|
|
|
/>
|
|
|
|
|
|
|
|
{account && (
|
|
|
|
<>
|
|
|
|
<SidebarNavigationLink
|
2022-04-07 11:47:06 -07:00
|
|
|
to={`/@${account.acct}`}
|
2022-03-21 11:09:01 -07:00
|
|
|
icon={require('icons/user.svg')}
|
|
|
|
text={<FormattedMessage id='tabs_bar.profile' defaultMessage='Profile' />}
|
|
|
|
/>
|
|
|
|
|
|
|
|
<SidebarNavigationLink
|
|
|
|
to='/notifications'
|
|
|
|
icon={require('icons/alert.svg')}
|
|
|
|
count={notificationCount}
|
2022-04-12 18:10:47 -07:00
|
|
|
text={<FormattedMessage id='tabs_bar.notifications' defaultMessage='Notifications' />}
|
2022-03-21 11:09:01 -07:00
|
|
|
/>
|
|
|
|
|
|
|
|
<SidebarNavigationLink
|
|
|
|
to='/settings'
|
|
|
|
icon={require('icons/cog.svg')}
|
|
|
|
text={<FormattedMessage id='tabs_bar.settings' defaultMessage='Settings' />}
|
|
|
|
/>
|
|
|
|
</>
|
|
|
|
)}
|
|
|
|
|
|
|
|
{account && (
|
|
|
|
features.chats ? (
|
|
|
|
<SidebarNavigationLink
|
|
|
|
to='/chats'
|
|
|
|
icon={require('@tabler/icons/icons/messages.svg')}
|
|
|
|
count={chatsCount}
|
|
|
|
text={<FormattedMessage id='tabs_bar.chats' defaultMessage='Chats' />}
|
|
|
|
/>
|
|
|
|
) : (
|
|
|
|
<SidebarNavigationLink
|
|
|
|
to='/messages'
|
|
|
|
icon={require('icons/mail.svg')}
|
|
|
|
text={<FormattedMessage id='navigation.direct_messages' defaultMessage='Messages' />}
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
)}
|
|
|
|
|
2022-04-01 17:35:57 -07:00
|
|
|
{/* {(account && account.staff) && (
|
2022-03-21 11:09:01 -07:00
|
|
|
<SidebarNavigationLink
|
|
|
|
to='/admin'
|
|
|
|
icon={location.pathname.startsWith('/admin') ? require('icons/dashboard-filled.svg') : require('@tabler/icons/icons/dashboard.svg')}
|
|
|
|
text={<FormattedMessage id='tabs_bar.dashboard' defaultMessage='Dashboard' />}
|
|
|
|
count={dashboardCount}
|
|
|
|
/>
|
|
|
|
)} */}
|
|
|
|
|
2022-04-07 11:47:06 -07:00
|
|
|
{(account && instance.invites_enabled) && (
|
2022-03-21 11:09:01 -07:00
|
|
|
<SidebarNavigationLink
|
|
|
|
to={`${baseURL}/invites`}
|
|
|
|
icon={require('@tabler/icons/icons/mailbox.svg')}
|
|
|
|
text={<FormattedMessage id='navigation.invites' defaultMessage='Invites' />}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
|
|
|
|
{(settings.get('isDeveloper')) && (
|
|
|
|
<SidebarNavigationLink
|
|
|
|
to='/developers'
|
|
|
|
icon={require('@tabler/icons/icons/code.svg')}
|
|
|
|
text={<FormattedMessage id='navigation.developers' defaultMessage='Developers' />}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
|
2022-04-12 18:10:47 -07:00
|
|
|
{(features.localTimeline || features.publicTimeline) && (
|
|
|
|
<hr className='dark:border-slate-700' />
|
2022-03-21 11:09:01 -07:00
|
|
|
)}
|
|
|
|
|
2022-04-12 18:10:47 -07:00
|
|
|
{features.localTimeline && (
|
|
|
|
<SidebarNavigationLink
|
|
|
|
to='/timeline/local'
|
|
|
|
icon={features.federating ? require('@tabler/icons/icons/users.svg') : require('@tabler/icons/icons/world.svg')}
|
|
|
|
text={features.federating ? instance.title : <FormattedMessage id='tabs_bar.all' defaultMessage='All' />}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
|
|
|
|
{(features.publicTimeline && features.federating) && (
|
|
|
|
<SidebarNavigationLink
|
|
|
|
to='/timeline/fediverse'
|
|
|
|
icon={require('icons/fediverse.svg')}
|
|
|
|
text={<FormattedMessage id='tabs_bar.fediverse' defaultMessage='Fediverse' />}
|
|
|
|
/>
|
|
|
|
)}
|
2022-03-21 11:09:01 -07:00
|
|
|
</div>
|
|
|
|
|
|
|
|
{account && (
|
|
|
|
<ComposeButton />
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default SidebarNavigation;
|