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-05-11 02:59:47 +02:00
|
|
|
|
2017-06-06 06:21:55 +02:00
|
|
|
const SearchNoResults = props => {
|
2017-10-06 23:46:41 +02:00
|
|
|
const { query } = props;
|
2017-05-11 02:59:47 +02:00
|
|
|
|
2017-06-06 23:19:12 +02:00
|
|
|
return (
|
|
|
|
<section>
|
|
|
|
<span className="empty">
|
|
|
|
{(__("No one has checked anything in for %s yet."), query)} {" "}
|
2017-10-06 23:46:41 +02:00
|
|
|
<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-05-11 02:59:47 +02:00
|
|
|
|
2017-06-08 06:42:19 +02:00
|
|
|
class FileListSearch extends React.PureComponent {
|
2017-05-11 02:59:47 +02:00
|
|
|
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);
|
2017-05-11 02:59:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
2017-10-06 23:46:41 +02:00
|
|
|
const { isSearching, uris, query } = this.props;
|
2017-05-11 02:59:47 +02:00
|
|
|
|
|
|
|
return (
|
2017-05-23 10:59:35 +02:00
|
|
|
<div>
|
2017-06-06 23:19:12 +02:00
|
|
|
{isSearching &&
|
2017-10-06 23:46:41 +02:00
|
|
|
!uris &&
|
2017-05-26 16:13:16 +02:00
|
|
|
<BusyMessage message={__("Looking up the Dewey Decimals")} />}
|
2017-05-23 10:59:35 +02:00
|
|
|
|
2017-06-06 23:19:12 +02:00
|
|
|
{isSearching &&
|
2017-10-06 23:46:41 +02:00
|
|
|
uris &&
|
2017-05-26 16:13:16 +02:00
|
|
|
<BusyMessage message={__("Refreshing the Dewey Decimals")} />}
|
2017-05-23 10:59:35 +02:00
|
|
|
|
2017-10-06 23:46:41 +02:00
|
|
|
{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} />
|
|
|
|
)
|
2017-10-06 23:46:41 +02:00
|
|
|
: !isSearching && <SearchNoResults query={query} />}
|
2017-05-23 10:59:35 +02:00
|
|
|
</div>
|
2017-06-06 23:19:12 +02:00
|
|
|
);
|
2017-05-11 02:59:47 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-06 06:21:55 +02:00
|
|
|
export default FileListSearch;
|