bump lightouse throttle

This commit is contained in:
zeppi 2021-06-16 14:11:45 -04:00 committed by jessopb
parent 48bc887b1f
commit e5b0c85747

View file

@ -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);
}
})