2023-05-23 10:52:27 +02:00
|
|
|
import { PureComponent } from 'react';
|
2022-02-25 00:34:33 +01:00
|
|
|
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
|
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import Column from 'mastodon/components/column';
|
|
|
|
import ColumnHeader from 'mastodon/components/column_header';
|
|
|
|
import { NavLink, Switch, Route } from 'react-router-dom';
|
|
|
|
import Links from './links';
|
|
|
|
import Tags from './tags';
|
|
|
|
import Statuses from './statuses';
|
|
|
|
import Suggestions from './suggestions';
|
|
|
|
import Search from 'mastodon/features/compose/containers/search_container';
|
|
|
|
import SearchResults from './results';
|
2022-09-29 04:39:33 +02:00
|
|
|
import { Helmet } from 'react-helmet';
|
2022-10-25 19:03:16 +02:00
|
|
|
import { showTrends } from 'mastodon/initial_state';
|
2022-02-25 00:34:33 +01:00
|
|
|
|
|
|
|
const messages = defineMessages({
|
|
|
|
title: { id: 'explore.title', defaultMessage: 'Explore' },
|
|
|
|
searchResults: { id: 'explore.search_results', defaultMessage: 'Search results' },
|
|
|
|
});
|
|
|
|
|
|
|
|
const mapStateToProps = state => ({
|
|
|
|
layout: state.getIn(['meta', 'layout']),
|
2022-10-25 19:03:16 +02:00
|
|
|
isSearching: state.getIn(['search', 'submitted']) || !showTrends,
|
2022-02-25 00:34:33 +01:00
|
|
|
});
|
|
|
|
|
2023-05-23 10:52:27 +02:00
|
|
|
class Explore extends PureComponent {
|
2022-02-25 00:34:33 +01:00
|
|
|
|
|
|
|
static contextTypes = {
|
|
|
|
router: PropTypes.object,
|
2022-10-04 20:13:23 +02:00
|
|
|
identity: PropTypes.object,
|
2022-02-25 00:34:33 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
intl: PropTypes.object.isRequired,
|
|
|
|
multiColumn: PropTypes.bool,
|
|
|
|
isSearching: PropTypes.bool,
|
|
|
|
};
|
|
|
|
|
|
|
|
handleHeaderClick = () => {
|
|
|
|
this.column.scrollTop();
|
2023-01-30 01:45:35 +01:00
|
|
|
};
|
2022-02-25 00:34:33 +01:00
|
|
|
|
|
|
|
setRef = c => {
|
|
|
|
this.column = c;
|
2023-01-30 01:45:35 +01:00
|
|
|
};
|
2022-02-25 00:34:33 +01:00
|
|
|
|
2022-11-17 08:54:43 +01:00
|
|
|
render() {
|
2022-10-04 20:13:23 +02:00
|
|
|
const { intl, multiColumn, isSearching } = this.props;
|
|
|
|
const { signedIn } = this.context.identity;
|
2022-02-25 00:34:33 +01:00
|
|
|
|
|
|
|
return (
|
|
|
|
<Column bindToDocument={!multiColumn} ref={this.setRef} label={intl.formatMessage(messages.title)}>
|
2022-10-04 20:13:23 +02:00
|
|
|
<ColumnHeader
|
|
|
|
icon={isSearching ? 'search' : 'hashtag'}
|
|
|
|
title={intl.formatMessage(isSearching ? messages.searchResults : messages.title)}
|
|
|
|
onClick={this.handleHeaderClick}
|
|
|
|
multiColumn={multiColumn}
|
|
|
|
/>
|
|
|
|
|
|
|
|
<div className='explore__search-header'>
|
|
|
|
<Search />
|
|
|
|
</div>
|
2022-02-25 00:34:33 +01:00
|
|
|
|
|
|
|
<div className='scrollable scrollable--flex'>
|
|
|
|
{isSearching ? (
|
|
|
|
<SearchResults />
|
|
|
|
) : (
|
2022-12-15 16:20:46 +01:00
|
|
|
<>
|
2022-02-25 00:34:33 +01:00
|
|
|
<div className='account__section-headline'>
|
2022-12-15 16:20:46 +01:00
|
|
|
<NavLink exact to='/explore'>
|
|
|
|
<FormattedMessage tagName='div' id='explore.trending_statuses' defaultMessage='Posts' />
|
|
|
|
</NavLink>
|
2023-04-28 08:54:20 +02:00
|
|
|
|
2022-12-15 16:20:46 +01:00
|
|
|
<NavLink exact to='/explore/tags'>
|
|
|
|
<FormattedMessage tagName='div' id='explore.trending_tags' defaultMessage='Hashtags' />
|
|
|
|
</NavLink>
|
2023-04-28 08:54:20 +02:00
|
|
|
|
2022-12-15 16:20:46 +01:00
|
|
|
{signedIn && (
|
|
|
|
<NavLink exact to='/explore/suggestions'>
|
2023-04-28 08:54:20 +02:00
|
|
|
<FormattedMessage tagName='div' id='explore.suggested_follows' defaultMessage='People' />
|
2022-12-15 16:20:46 +01:00
|
|
|
</NavLink>
|
|
|
|
)}
|
2023-04-28 08:54:20 +02:00
|
|
|
|
|
|
|
<NavLink exact to='/explore/links'>
|
|
|
|
<FormattedMessage tagName='div' id='explore.trending_links' defaultMessage='News' />
|
|
|
|
</NavLink>
|
2022-02-25 00:34:33 +01:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<Switch>
|
|
|
|
<Route path='/explore/tags' component={Tags} />
|
|
|
|
<Route path='/explore/links' component={Links} />
|
|
|
|
<Route path='/explore/suggestions' component={Suggestions} />
|
2023-03-30 10:14:49 +02:00
|
|
|
<Route exact path={['/explore', '/explore/posts', '/search']}>
|
|
|
|
<Statuses multiColumn={multiColumn} />
|
|
|
|
</Route>
|
2022-02-25 00:34:33 +01:00
|
|
|
</Switch>
|
2022-09-29 04:39:33 +02:00
|
|
|
|
|
|
|
<Helmet>
|
2022-10-09 03:55:09 +02:00
|
|
|
<title>{intl.formatMessage(messages.title)}</title>
|
2022-10-20 14:35:29 +02:00
|
|
|
<meta name='robots' content={isSearching ? 'noindex' : 'all'} />
|
2022-09-29 04:39:33 +02:00
|
|
|
</Helmet>
|
2022-12-15 16:20:46 +01:00
|
|
|
</>
|
2022-02-25 00:34:33 +01:00
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
</Column>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2023-03-24 03:17:53 +01:00
|
|
|
|
|
|
|
export default connect(mapStateToProps)(injectIntl(Explore));
|