lbry-desktop/ui/js/component/fileListSearch/view.jsx

63 lines
1.5 KiB
React
Raw Normal View History

2017-06-06 23:19:12 +02:00
import React from "react";
import FileTile from "component/fileTile";
2017-10-10 01:19:50 +02:00
import ChannelTile from "component/channelTile";
2017-06-06 23:19:12 +02:00
import Link from "component/link";
import { BusyMessage } from "component/common.js";
2017-10-10 01:19:50 +02:00
import lbryuri from "lbryuri";
2017-06-06 06:21:55 +02:00
const SearchNoResults = props => {
const { query } = props;
2017-06-06 23:19:12 +02:00
return (
<section>
<span className="empty">
{(__("No one has checked anything in for %s yet."), query)} {" "}
<Link label={__("Be the first")} navigate="/publish" />
2017-06-06 23:19:12 +02:00
</span>
</section>
);
2017-06-06 06:21:55 +02:00
};
2017-06-08 06:42:19 +02:00
class FileListSearch extends React.PureComponent {
componentWillMount() {
2017-09-17 20:26:55 +02:00
this.doSearch(this.props);
}
componentWillReceiveProps(props) {
if (props.query != this.props.query) {
this.doSearch(props);
}
}
doSearch(props) {
this.props.search(props.query);
}
render() {
const { isSearching, uris, query } = this.props;
return (
<div>
2017-06-06 23:19:12 +02:00
{isSearching &&
!uris &&
<BusyMessage message={__("Looking up the Dewey Decimals")} />}
2017-06-06 23:19:12 +02:00
{isSearching &&
uris &&
<BusyMessage message={__("Refreshing the Dewey Decimals")} />}
{uris && uris.length
2017-10-10 01:19:50 +02:00
? uris.map(
uri =>
lbryuri.parse(uri).name[0] === "@"
? <ChannelTile key={uri} uri={uri} />
: <FileTile key={uri} uri={uri} />
)
: !isSearching && <SearchNoResults query={query} />}
</div>
2017-06-06 23:19:12 +02:00
);
}
}
2017-06-06 06:21:55 +02:00
export default FileListSearch;