fix bad lighthouse results

This commit is contained in:
zeppi 2021-01-28 14:03:37 -05:00 committed by Sean Yesmunt
parent 4c97cb4ba4
commit 6a16d8e0cd
2 changed files with 6 additions and 3 deletions

View file

@ -2,6 +2,7 @@
import React from 'react'; import React from 'react';
import { lighthouse } from 'redux/actions/search'; import { lighthouse } from 'redux/actions/search';
import { getSearchQueryString } from 'util/query-params'; import { getSearchQueryString } from 'util/query-params';
import { isURIValid } from 'lbry-redux';
import useThrottle from './use-throttle'; import useThrottle from './use-throttle';
export default function useLighthouse(query: string, showMature?: boolean, size?: number = 5) { export default function useLighthouse(query: string, showMature?: boolean, size?: number = 5) {
@ -20,7 +21,7 @@ export default function useLighthouse(query: string, showMature?: boolean, size?
.search(throttledQuery) .search(throttledQuery)
.then(results => { .then(results => {
if (isSubscribed) { if (isSubscribed) {
setResults(results.map(result => `lbry://${result.name}#${result.claimId}`)); setResults(results.map(result => `lbry://${result.name}#${result.claimId}`).filter(uri => isURIValid(uri)));
setLoading(false); setLoading(false);
} }
}) })

View file

@ -1,6 +1,6 @@
// @flow // @flow
import * as ACTIONS from 'constants/action_types'; import * as ACTIONS from 'constants/action_types';
import { buildURI, doResolveUris, batchActions } from 'lbry-redux'; import { buildURI, doResolveUris, batchActions, isURIValid } from 'lbry-redux';
import { makeSelectSearchUris, makeSelectQueryWithOptions, selectSearchValue } from 'redux/selectors/search'; import { makeSelectSearchUris, makeSelectQueryWithOptions, selectSearchValue } from 'redux/selectors/search';
import handleFetchResponse from 'util/handle-fetch'; import handleFetchResponse from 'util/handle-fetch';
@ -71,8 +71,10 @@ export const doSearch = (rawQuery: string, searchOptions: SearchOptions) => (
} }
const url = buildURI(urlObj); const url = buildURI(urlObj);
if (isURIValid(url)) {
uris.push(url); uris.push(url);
} }
}
}); });
actions.push(doResolveUris(uris)); actions.push(doResolveUris(uris));