// Package imports. import PropTypes from 'prop-types'; import React from 'react'; import ImmutablePropTypes from 'react-immutable-proptypes'; import { FormattedMessage, defineMessages, } from 'react-intl'; import spring from 'react-motion/lib/spring'; import { Link } from 'react-router-dom'; // Components. import Icon from 'flavours/glitch/components/icon'; import AccountContainer from 'flavours/glitch/containers/account_container'; import StatusContainer from 'flavours/glitch/containers/status_container'; import Hashtag from 'flavours/glitch/components/hashtag'; // Utils. import Motion from 'flavours/glitch/util/optional_motion'; // Messages. const messages = defineMessages({ total: { defaultMessage: '{count, number} {count, plural, one {result} other {results}}', id: 'search_results.total', }, }); // The component. export default function DrawerResults ({ results, visible, }) { const accounts = results ? results.get('accounts') : null; const statuses = results ? results.get('statuses') : null; const hashtags = results ? results.get('hashtags') : null; // This gets the total number of items. const count = [accounts, statuses, hashtags].reduce(function (size, item) { if (item && item.size) { return size + item.size; } return size; }, 0); // The result. return ( {({ x }) => (
{accounts && accounts.size ? (
{accounts.map( accountId => ( ) )}
) : null} {statuses && statuses.size ? (
{statuses.map( statusId => ( ) )}
) : null} {hashtags && hashtags.size ? (
{hashtags.map(hashtag => )}
) : null}
)}
); } // Props. DrawerResults.propTypes = { results: ImmutablePropTypes.map, visible: PropTypes.bool, };