import React from 'react'; import PropTypes from 'prop-types'; import { FormattedMessage } from 'react-intl'; import ImmutablePropTypes from 'react-immutable-proptypes'; import AccountContainer from '../../../containers/account_container'; import StatusContainer from '../../../containers/status_container'; import ImmutablePureComponent from 'react-immutable-pure-component'; import Hashtag from '../../../components/hashtag'; import LoadingIndicator from 'soapbox/components/loading_indicator'; import FilterBar from '../../search/components/filter_bar'; import LoadMore from '../../../components/load_more'; import classNames from 'classnames'; export default class SearchResults extends ImmutablePureComponent { static propTypes = { value: ImmutablePropTypes.string, results: ImmutablePropTypes.map.isRequired, submitted: PropTypes.bool, expandSearch: PropTypes.func.isRequired, selectedFilter: PropTypes.string.isRequired, selectFilter: PropTypes.func.isRequired, }; handleLoadMore = () => this.props.expandSearch(this.props.selectedFilter); handleSelectFilter = newActiveFilter => this.props.selectFilter(newActiveFilter); render() { const { value, results, submitted, selectedFilter } = this.props; if (submitted && results.isEmpty()) { return (
); } let searchResults; let hasMore = false; if (selectedFilter === 'accounts' && results.get('accounts')) { hasMore = results.get('accountsHasMore'); searchResults = results.get('accounts').size > 0 ? (
{results.get('accounts').map(accountId => )}
) : (
); } if (selectedFilter === 'statuses' && results.get('statuses')) { hasMore = results.get('statusesHasMore'); searchResults = results.get('statuses').size > 0 ? (
{results.get('statuses').map(statusId => )}
) : (
); } if (selectedFilter === 'hashtags' && results.get('hashtags')) { hasMore = results.get('hashtagsHasMore'); searchResults = results.get('hashtags').size > 0 ? (
{results.get('hashtags').map(hashtag => )}
) : (
); } return ( <> {submitted && } {searchResults} {hasMore && } ); } }