You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
108 lines
3.7 KiB
108 lines
3.7 KiB
3 years ago
|
import React from 'react';
|
||
|
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
|
||
|
import { connect } from 'react-redux';
|
||
|
import PropTypes from 'prop-types';
|
||
|
import Column from 'flavours/glitch/components/column';
|
||
|
import ColumnHeader from 'flavours/glitch/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 'flavours/glitch/features/compose/containers/search_container';
|
||
|
import SearchResults from './results';
|
||
2 years ago
|
import { showTrends } from 'flavours/glitch/initial_state';
|
||
2 years ago
|
import { Helmet } from 'react-helmet';
|
||
3 years ago
|
|
||
|
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']),
|
||
2 years ago
|
isSearching: state.getIn(['search', 'submitted']) || !showTrends,
|
||
3 years ago
|
});
|
||
|
|
||
|
export default @connect(mapStateToProps)
|
||
|
@injectIntl
|
||
|
class Explore extends React.PureComponent {
|
||
|
|
||
|
static contextTypes = {
|
||
|
router: PropTypes.object,
|
||
2 years ago
|
identity: PropTypes.object,
|
||
3 years ago
|
};
|
||
|
|
||
|
static propTypes = {
|
||
|
intl: PropTypes.object.isRequired,
|
||
|
multiColumn: PropTypes.bool,
|
||
|
isSearching: PropTypes.bool,
|
||
|
};
|
||
|
|
||
|
handleHeaderClick = () => {
|
||
|
this.column.scrollTop();
|
||
2 years ago
|
};
|
||
3 years ago
|
|
||
|
setRef = c => {
|
||
|
this.column = c;
|
||
2 years ago
|
};
|
||
3 years ago
|
|
||
2 years ago
|
render() {
|
||
2 years ago
|
const { intl, multiColumn, isSearching } = this.props;
|
||
|
const { signedIn } = this.context.identity;
|
||
3 years ago
|
|
||
|
return (
|
||
|
<Column bindToDocument={!multiColumn} ref={this.setRef} label={intl.formatMessage(messages.title)}>
|
||
2 years ago
|
<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>
|
||
3 years ago
|
|
||
|
<div className='scrollable scrollable--flex'>
|
||
|
{isSearching ? (
|
||
|
<SearchResults />
|
||
|
) : (
|
||
2 years ago
|
<>
|
||
3 years ago
|
<div className='account__section-headline'>
|
||
2 years ago
|
<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>
|
||
|
<NavLink exact to='/explore/links'>
|
||
|
<FormattedMessage tagName='div' id='explore.trending_links' defaultMessage='News' />
|
||
|
</NavLink>
|
||
|
{signedIn && (
|
||
|
<NavLink exact to='/explore/suggestions'>
|
||
|
<FormattedMessage tagName='div' id='explore.suggested_follows' defaultMessage='For you' />
|
||
|
</NavLink>
|
||
|
)}
|
||
3 years ago
|
</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']} component={Statuses} componentParams={{ multiColumn }} />
|
||
|
</Switch>
|
||
2 years ago
|
|
||
|
<Helmet>
|
||
2 years ago
|
<title>{intl.formatMessage(messages.title)}</title>
|
||
2 years ago
|
<meta name='robots' content={isSearching ? 'noindex' : 'all'} />
|
||
2 years ago
|
</Helmet>
|
||
2 years ago
|
</>
|
||
3 years ago
|
)}
|
||
|
</div>
|
||
|
</Column>
|
||
|
);
|
||
|
}
|
||
|
|
||
|
}
|