2018-03-26 23:32:43 +02:00
|
|
|
// @flow
|
|
|
|
import * as React from 'react';
|
2018-01-19 16:12:28 +01:00
|
|
|
import { isURIValid, normalizeURI } from 'lbryURI';
|
2017-12-21 22:08:54 +01:00
|
|
|
import FileTile from 'component/fileTile';
|
|
|
|
import FileListSearch from 'component/fileListSearch';
|
2018-03-26 23:32:43 +02:00
|
|
|
import ToolTip from 'component/common/tooltip';
|
|
|
|
import Page from 'component/page';
|
2017-05-05 10:01:16 +02:00
|
|
|
|
2018-03-26 23:32:43 +02:00
|
|
|
const MODAL_ANIMATION_TIME = 250;
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
query: ?string,
|
|
|
|
updateSearchQuery: string => void,
|
|
|
|
};
|
|
|
|
|
|
|
|
class SearchPage extends React.PureComponent<Props> {
|
|
|
|
constructor() {
|
|
|
|
super();
|
2017-05-11 02:59:47 +02:00
|
|
|
|
2018-03-26 23:32:43 +02:00
|
|
|
this.input = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
componentDidMount() {
|
|
|
|
// Wait for the modal to animate down before focusing
|
|
|
|
// without this there is an issue with scroll the page down
|
|
|
|
setTimeout(() => {
|
|
|
|
if (this.input) {
|
|
|
|
this.input.focus();
|
|
|
|
}
|
|
|
|
}, MODAL_ANIMATION_TIME);
|
|
|
|
}
|
|
|
|
|
|
|
|
input: ?HTMLInputElement;
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const { query, updateSearchQuery } = this.props;
|
2017-05-11 02:59:47 +02:00
|
|
|
return (
|
2018-03-26 23:32:43 +02:00
|
|
|
<Page noPadding>
|
|
|
|
<div className="search__wrapper">
|
|
|
|
<input
|
|
|
|
ref={input => (this.input = input)}
|
|
|
|
className="search__input"
|
|
|
|
value={query}
|
|
|
|
placeholder={__('Search for anything...')}
|
|
|
|
onChange={event => updateSearchQuery(event.target.value)}
|
|
|
|
/>
|
|
|
|
|
|
|
|
{isURIValid(query) && (
|
|
|
|
<React.Fragment>
|
|
|
|
<div className="file-list__header">
|
|
|
|
{__('Exact URL')}
|
|
|
|
<ToolTip
|
|
|
|
label="?"
|
|
|
|
body={__('This is the resolution of a LBRY URL and not controlled by LBRY Inc.')}
|
|
|
|
className="tooltip--header"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<FileTile fullWidth uri={normalizeURI(query)} showUri />
|
|
|
|
</React.Fragment>
|
|
|
|
)}
|
2017-05-11 02:59:47 +02:00
|
|
|
<FileListSearch query={query} />
|
2018-03-26 23:32:43 +02:00
|
|
|
</div>
|
|
|
|
</Page>
|
2017-06-06 23:19:12 +02:00
|
|
|
);
|
2017-05-11 02:59:47 +02:00
|
|
|
}
|
2017-05-05 10:01:16 +02:00
|
|
|
}
|
2018-03-26 23:32:43 +02:00
|
|
|
|
2017-05-05 10:01:16 +02:00
|
|
|
export default SearchPage;
|