From 9343f5855c489ac4a937465864e831e9d30b8344 Mon Sep 17 00:00:00 2001 From: Sean Yesmunt Date: Tue, 11 Feb 2020 13:36:17 -0500 Subject: [PATCH] fix winning claim for top search results --- ui/page/search/view.jsx | 40 +++++++++++------------------- ui/scss/component/_claim-list.scss | 2 +- 2 files changed, 15 insertions(+), 27 deletions(-) diff --git a/ui/page/search/view.jsx b/ui/page/search/view.jsx index ab6c0f573..85dd11c2d 100644 --- a/ui/page/search/view.jsx +++ b/ui/page/search/view.jsx @@ -1,7 +1,7 @@ // @flow import * as ICONS from 'constants/icons'; import React, { useEffect, Fragment } from 'react'; -import { isURIValid, normalizeURI, regexInvalidURI } from 'lbry-redux'; +import { regexInvalidURI } from 'lbry-redux'; import ClaimPreview from 'component/claimPreview'; import ClaimList from 'component/claimList'; import Page from 'component/page'; @@ -27,28 +27,18 @@ type Props = { export default function SearchPage(props: Props) { const { search, uris, onFeedbackPositive, onFeedbackNegative, location, isSearching, showNsfw } = props; const urlParams = new URLSearchParams(location.search); - const urlQuery = urlParams.get('q'); + const urlQuery = urlParams.get('q') || ''; const additionalOptions: AdditionalOptions = { isBackgroundSearch: false }; if (!showNsfw) { additionalOptions['nsfw'] = false; } - let normalizedUri; - let isUriValid; - if (isURIValid(urlQuery)) { - isUriValid = true; - normalizedUri = normalizeURI(urlQuery); - } else { - let INVALID_URI_CHARS = new RegExp(regexInvalidURI, 'gu'); - let modifiedUrlQuery = urlQuery - ? urlQuery - .trim() - .replace(/\s+/g, '-') - .replace(INVALID_URI_CHARS, '') - : ''; - isUriValid = isURIValid(modifiedUrlQuery); - normalizedUri = isUriValid && normalizeURI(modifiedUrlQuery); - } + const INVALID_URI_CHARS = new RegExp(regexInvalidURI, 'gu'); + const modifiedUrlQuery = urlQuery + .trim() + .replace(/\s+/g, '-') + .replace(INVALID_URI_CHARS, ''); + const uriFromQuery = `lbry://${modifiedUrlQuery}`; useEffect(() => { if (urlQuery) { @@ -61,14 +51,12 @@ export default function SearchPage(props: Props) {
{urlQuery && ( - {isUriValid && ( -
- -
- -
-
- )} +
+ +
+ +
+