import React from 'react'; 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'; import { Helmet } from 'react-helmet'; import { showTrends } from 'mastodon/initial_state'; 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']), isSearching: state.getIn(['search', 'submitted']) || !showTrends, }); // Fix strange bug on Safari where (rendered by FormattedMessage) disappears // after clicking around Explore top bar (issue #20885). // Removing width=100% from also fixes it, as well as replacing with
// We're choosing to wrap span with div to keep the changes local only to this tool bar. const WrapFormattedMessage = ({ children, ...props }) =>
{children}
; WrapFormattedMessage.propTypes = { children: PropTypes.any, }; export default @connect(mapStateToProps) @injectIntl class Explore extends React.PureComponent { static contextTypes = { router: PropTypes.object, identity: PropTypes.object, }; static propTypes = { intl: PropTypes.object.isRequired, multiColumn: PropTypes.bool, isSearching: PropTypes.bool, }; handleHeaderClick = () => { this.column.scrollTop(); } setRef = c => { this.column = c; } render() { const { intl, multiColumn, isSearching } = this.props; const { signedIn } = this.context.identity; return (
{isSearching ? ( ) : (
{signedIn && }
{intl.formatMessage(messages.title)}
)}
); } }