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