|
|
@ -1,5 +1,6 @@
|
|
|
|
import React from 'react';
|
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
|
|
|
import { FormattedMessage } from 'react-intl';
|
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
|
|
|
import AccountContainer from '../../../containers/account_container';
|
|
|
|
import AccountContainer from '../../../containers/account_container';
|
|
|
|
import StatusContainer from '../../../containers/status_container';
|
|
|
|
import StatusContainer from '../../../containers/status_container';
|
|
|
@ -13,6 +14,7 @@ import classNames from 'classnames';
|
|
|
|
export default class SearchResults extends ImmutablePureComponent {
|
|
|
|
export default class SearchResults extends ImmutablePureComponent {
|
|
|
|
|
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
static propTypes = {
|
|
|
|
|
|
|
|
value: ImmutablePropTypes.string,
|
|
|
|
results: ImmutablePropTypes.map.isRequired,
|
|
|
|
results: ImmutablePropTypes.map.isRequired,
|
|
|
|
submitted: PropTypes.bool,
|
|
|
|
submitted: PropTypes.bool,
|
|
|
|
expandSearch: PropTypes.func.isRequired,
|
|
|
|
expandSearch: PropTypes.func.isRequired,
|
|
|
@ -24,7 +26,7 @@ export default class SearchResults extends ImmutablePureComponent {
|
|
|
|
handleSelectFilter = newActiveFilter => this.props.selectFilter(newActiveFilter);
|
|
|
|
handleSelectFilter = newActiveFilter => this.props.selectFilter(newActiveFilter);
|
|
|
|
|
|
|
|
|
|
|
|
render() {
|
|
|
|
render() {
|
|
|
|
const { results, submitted, selectedFilter } = this.props;
|
|
|
|
const { value, results, submitted, selectedFilter } = this.props;
|
|
|
|
|
|
|
|
|
|
|
|
if (submitted && results.isEmpty()) {
|
|
|
|
if (submitted && results.isEmpty()) {
|
|
|
|
return (
|
|
|
|
return (
|
|
|
@ -37,33 +39,57 @@ export default class SearchResults extends ImmutablePureComponent {
|
|
|
|
let searchResults;
|
|
|
|
let searchResults;
|
|
|
|
let hasMore = false;
|
|
|
|
let hasMore = false;
|
|
|
|
|
|
|
|
|
|
|
|
if (selectedFilter === 'accounts' && results.get('accounts') && results.get('accounts').size > 0) {
|
|
|
|
if (selectedFilter === 'accounts' && results.get('accounts')) {
|
|
|
|
hasMore = results.get('accountsHasMore');
|
|
|
|
hasMore = results.get('accountsHasMore');
|
|
|
|
|
|
|
|
|
|
|
|
searchResults = (
|
|
|
|
searchResults = results.get('accounts').size > 0 ? (
|
|
|
|
<div className={classNames('search-results__section', { 'has-more': hasMore })}>
|
|
|
|
<div className={classNames('search-results__section', { 'has-more': hasMore })}>
|
|
|
|
{results.get('accounts').map(accountId => <AccountContainer key={accountId} id={accountId} />)}
|
|
|
|
{results.get('accounts').map(accountId => <AccountContainer key={accountId} id={accountId} />)}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
) : (
|
|
|
|
|
|
|
|
<div className='empty-column-indicator'>
|
|
|
|
|
|
|
|
<FormattedMessage
|
|
|
|
|
|
|
|
id='empty_column.search.accounts'
|
|
|
|
|
|
|
|
defaultMessage='There are no people results for "{term}"'
|
|
|
|
|
|
|
|
values={{ term: value }}
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (selectedFilter === 'statuses' && results.get('statuses') && results.get('statuses').size > 0) {
|
|
|
|
if (selectedFilter === 'statuses' && results.get('statuses')) {
|
|
|
|
hasMore = results.get('statusesHasMore');
|
|
|
|
hasMore = results.get('statusesHasMore');
|
|
|
|
|
|
|
|
|
|
|
|
searchResults = (
|
|
|
|
searchResults = results.get('statuses').size > 0 ? (
|
|
|
|
<div className={classNames('search-results__section', { 'has-more': hasMore })}>
|
|
|
|
<div className={classNames('search-results__section', { 'has-more': hasMore })}>
|
|
|
|
{results.get('statuses').map(statusId => <StatusContainer key={statusId} id={statusId} />)}
|
|
|
|
{results.get('statuses').map(statusId => <StatusContainer key={statusId} id={statusId} />)}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
) : (
|
|
|
|
|
|
|
|
<div className='empty-column-indicator'>
|
|
|
|
|
|
|
|
<FormattedMessage
|
|
|
|
|
|
|
|
id='empty_column.search.statuses'
|
|
|
|
|
|
|
|
defaultMessage='There are no posts results for "{term}"'
|
|
|
|
|
|
|
|
values={{ term: value }}
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (selectedFilter === 'hashtags' && results.get('hashtags') && results.get('hashtags').size > 0) {
|
|
|
|
if (selectedFilter === 'hashtags' && results.get('hashtags')) {
|
|
|
|
hasMore = results.get('hashtagsHasMore');
|
|
|
|
hasMore = results.get('hashtagsHasMore');
|
|
|
|
|
|
|
|
|
|
|
|
searchResults = (
|
|
|
|
searchResults = results.get('hashtags').size > 0 ? (
|
|
|
|
<div className={classNames('search-results__section', { 'has-more': hasMore })}>
|
|
|
|
<div className={classNames('search-results__section', { 'has-more': hasMore })}>
|
|
|
|
{results.get('hashtags').map(hashtag => <Hashtag key={hashtag.get('name')} hashtag={hashtag} />)}
|
|
|
|
{results.get('hashtags').map(hashtag => <Hashtag key={hashtag.get('name')} hashtag={hashtag} />)}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
) : (
|
|
|
|
|
|
|
|
<div className='empty-column-indicator'>
|
|
|
|
|
|
|
|
<FormattedMessage
|
|
|
|
|
|
|
|
id='empty_column.search.hashtags'
|
|
|
|
|
|
|
|
defaultMessage='There are no hashtags results for "{term}"'
|
|
|
|
|
|
|
|
values={{ term: value }}
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|