Fix DMs link

This commit is contained in:
Alex Gleason 2022-04-30 11:45:58 -05:00
parent f19bd32e52
commit 28ead43f96
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7
4 changed files with 79 additions and 66 deletions

View file

@ -106,6 +106,32 @@ const SidebarNavigation = () => {
const menu = makeMenu(); const menu = makeMenu();
/** Conditionally render the supported messages link */
const renderMessagesLink = (): React.ReactNode => {
if (features.chats) {
return (
<SidebarNavigationLink
to='/chats'
icon={require('@tabler/icons/icons/messages.svg')}
count={chatsCount}
text={<FormattedMessage id='tabs_bar.chats' defaultMessage='Chats' />}
/>
);
}
if (features.directTimeline || features.conversations) {
return (
<SidebarNavigationLink
to='/messages'
icon={require('icons/mail.svg')}
text={<FormattedMessage id='navigation.direct_messages' defaultMessage='Messages' />}
/>
);
}
return null;
};
return ( return (
<div> <div>
<div className='flex flex-col space-y-2'> <div className='flex flex-col space-y-2'>
@ -138,22 +164,7 @@ const SidebarNavigation = () => {
</> </>
)} )}
{account && ( {account && renderMessagesLink()}
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' />}
/>
)
)}
{menu.length > 0 && ( {menu.length > 0 && (
<DropdownMenu items={menu}> <DropdownMenu items={menu}>

View file

@ -12,6 +12,34 @@ const ThumbNavigation: React.FC = (): JSX.Element => {
const dashboardCount = useAppSelector((state) => state.admin.openReports.count() + state.admin.awaitingApproval.count()); const dashboardCount = useAppSelector((state) => state.admin.openReports.count() + state.admin.awaitingApproval.count());
const features = getFeatures(useAppSelector((state) => state.instance)); const features = getFeatures(useAppSelector((state) => state.instance));
/** Conditionally render the supported messages link */
const renderMessagesLink = (): React.ReactNode => {
if (features.chats) {
return (
<ThumbNavigationLink
src={require('@tabler/icons/icons/messages.svg')}
text={<FormattedMessage id='navigation.chats' defaultMessage='Chats' />}
to='/chats'
exact
count={chatsCount}
/>
);
}
if (features.directTimeline || features.conversations) {
return (
<ThumbNavigationLink
src={require('@tabler/icons/icons/mail.svg')}
text={<FormattedMessage id='navigation.direct_messages' defaultMessage='Messages' />}
to='/messages'
paths={['/messages', '/conversations']}
/>
);
}
return null;
};
return ( return (
<div className='thumb-navigation'> <div className='thumb-navigation'>
<ThumbNavigationLink <ThumbNavigationLink
@ -38,24 +66,7 @@ const ThumbNavigation: React.FC = (): JSX.Element => {
/> />
)} )}
{account && ( {account && renderMessagesLink()}
features.chats ? (
<ThumbNavigationLink
src={require('@tabler/icons/icons/messages.svg')}
text={<FormattedMessage id='navigation.chats' defaultMessage='Chats' />}
to='/chats'
exact
count={chatsCount}
/>
) : (
<ThumbNavigationLink
src={require('@tabler/icons/icons/mail.svg')}
text={<FormattedMessage id='navigation.direct_messages' defaultMessage='Messages' />}
to='/messages'
paths={['/messages', '/conversations']}
/>
)
)}
{(account && account.staff) && ( {(account && account.staff) && (
<ThumbNavigationLink <ThumbNavigationLink

View file

@ -1,18 +1,20 @@
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import React from 'react'; import React from 'react';
import { defineMessages, injectIntl } from 'react-intl'; import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { directComposeById } from 'soapbox/actions/compose'; import { directComposeById } from 'soapbox/actions/compose';
import AccountSearch from 'soapbox/components/account_search';
import { mountConversations, unmountConversations, expandConversations } from '../../actions/conversations'; import { mountConversations, unmountConversations, expandConversations } from '../../actions/conversations';
import { connectDirectStream } from '../../actions/streaming'; import { connectDirectStream } from '../../actions/streaming';
import { Card, CardBody, Column, Stack, Text } from '../../components/ui'; import { Column } from '../../components/ui';
import ConversationsListContainer from './containers/conversations_list_container';
const messages = defineMessages({ const messages = defineMessages({
title: { id: 'column.direct', defaultMessage: 'Direct messages' }, title: { id: 'column.direct', defaultMessage: 'Direct messages' },
searchPlaceholder: { id: 'direct.search_placeholder', defaultMessage: 'Send a message to…' }, searchPlaceholder: { id: 'direct.search_placeholder', defaultMessage: 'Send a message to…' },
body: { id: 'direct.body', defaultMessage: 'A new direct messaging experience will be available soon. Please stay tuned.' },
}); });
export default @connect() export default @connect()
@ -54,35 +56,20 @@ class ConversationsTimeline extends React.PureComponent {
const { intl } = this.props; const { intl } = this.props;
return ( return (
<Column label={intl.formatMessage(messages.title)} transparent> <Column label={intl.formatMessage(messages.title)}>
<Card variant='rounded'> <AccountSearch
<CardBody> placeholder={intl.formatMessage(messages.searchPlaceholder)}
<Stack space={2}> onSelected={this.handleSuggestion}
<Text size='lg' align='center' weight='bold'>{intl.formatMessage(messages.title)}</Text> />
<Text theme='muted' align='center'>{intl.formatMessage(messages.body)}</Text>
</Stack> <ConversationsListContainer
</CardBody> scrollKey='direct_timeline'
</Card> timelineId='direct'
onLoadMore={this.handleLoadMore}
emptyMessage={<FormattedMessage id='empty_column.direct' defaultMessage="You don't have any direct messages yet. When you send or receive one, it will show up here." />}
/>
</Column> </Column>
); );
// return (
// <Column label={intl.formatMessage(messages.title)}>
// <ColumnHeader icon='envelope' active={hasUnread} title={intl.formatMessage(messages.title)} />
// <AccountSearch
// placeholder={intl.formatMessage(messages.searchPlaceholder)}
// onSelected={this.handleSuggestion}
// />
// <ConversationsListContainer
// scrollKey='direct_timeline'
// timelineId='direct'
// onLoadMore={this.handleLoadMore}
// emptyMessage={<FormattedMessage id='empty_column.direct' defaultMessage="You don't have any direct messages yet. When you send or receive one, it will show up here." />}
// />
// </Column>
// );
} }
} }

View file

@ -187,8 +187,12 @@ const SwitchingColumnsArea: React.FC = ({ children }) => {
{features.federating && <WrappedRoute path='/timeline/fediverse' exact page={HomePage} component={PublicTimeline} content={children} publicRoute />} {features.federating && <WrappedRoute path='/timeline/fediverse' exact page={HomePage} component={PublicTimeline} content={children} publicRoute />}
{features.federating && <WrappedRoute path='/timeline/:instance' exact page={RemoteInstancePage} component={RemoteTimeline} content={children} />} {features.federating && <WrappedRoute path='/timeline/:instance' exact page={RemoteInstancePage} component={RemoteTimeline} content={children} />}
<WrappedRoute path='/conversations' page={DefaultPage} component={Conversations} content={children} /> {features.conversations && <WrappedRoute path='/conversations' page={DefaultPage} component={Conversations} content={children} />}
<WrappedRoute path='/messages' page={DefaultPage} component={features.directTimeline ? DirectTimeline : Conversations} content={children} /> {features.directTimeline ? (
<WrappedRoute path='/messages' page={DefaultPage} component={DirectTimeline} content={children} />
) : (
<WrappedRoute path='/messages' page={DefaultPage} component={Conversations} content={children} />
)}
{/* Gab groups */} {/* Gab groups */}
{/* {/*