bump lightouse throttle
This commit is contained in:
parent
48bc887b1f
commit
e5b0c85747
1 changed files with 6 additions and 3 deletions
|
@ -6,10 +6,11 @@ import { isURIValid } from 'lbry-redux';
|
|||
import useThrottle from './use-throttle';
|
||||
|
||||
export default function useLighthouse(query: string, showMature?: boolean, size?: number = 5) {
|
||||
const THROTTLE_MS = 1000;
|
||||
const [results, setResults] = React.useState();
|
||||
const [loading, setLoading] = React.useState();
|
||||
const queryString = query ? getSearchQueryString(query, { nsfw: showMature, size }) : '';
|
||||
const throttledQuery = useThrottle(queryString, 500);
|
||||
const throttledQuery = useThrottle(queryString, THROTTLE_MS);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (throttledQuery) {
|
||||
|
@ -19,9 +20,11 @@ export default function useLighthouse(query: string, showMature?: boolean, size?
|
|||
let isSubscribed = true;
|
||||
lighthouse
|
||||
.search(throttledQuery)
|
||||
.then(results => {
|
||||
.then((results) => {
|
||||
if (isSubscribed) {
|
||||
setResults(results.map(result => `lbry://${result.name}#${result.claimId}`).filter(uri => isURIValid(uri)));
|
||||
setResults(
|
||||
results.map((result) => `lbry://${result.name}#${result.claimId}`).filter((uri) => isURIValid(uri))
|
||||
);
|
||||
setLoading(false);
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue