// @flow
import * as React from 'react';
import { parseURI } from 'lbry-redux';
import FileTile from 'component/fileTile';
import ChannelTile from 'component/channelTile';
import HiddenNsfwClaims from 'component/hiddenNsfwClaims';
const NoResults = () =>
{__('No results')}
;
type Props = {
query: string,
isSearching: boolean,
uris: ?Array,
downloadUris: ?Array,
};
class FileListSearch extends React.PureComponent {
render() {
const { uris, query, downloadUris, isSearching } = this.props;
const fileResults = [];
const channelResults = [];
if (uris && uris.length) {
uris.forEach(uri => {
const isChannel = parseURI(uri).claimName[0] === '@';
if (isChannel) {
channelResults.push(uri);
} else {
fileResults.push(uri);
}
});
}
return (
query && (
{__('Search Results')}
{!isSearching && fileResults.length ? (
fileResults.map(uri => )
) : (
)}
{__('Channels')}
{!isSearching && channelResults.length ? (
channelResults.map(uri => )
) : (
)}
{__('Your downloads')}
{downloadUris && downloadUris.length ? (
downloadUris.map(uri => (
))
) : (
)}
)
);
}
}
export default FileListSearch;