From 5c874e921769093428966fa7ecdf723719cb9067 Mon Sep 17 00:00:00 2001 From: Akinwale Ariwodola Date: Fri, 21 Feb 2020 17:12:45 +0100 Subject: [PATCH] fix selector for resolved related content --- dist/bundle.es.js | 16 +++++++--------- src/redux/selectors/claims.js | 6 +----- src/util/query-params.js | 34 ++++++++++++++++++---------------- 3 files changed, 26 insertions(+), 30 deletions(-) diff --git a/dist/bundle.es.js b/dist/bundle.es.js index 4f63f2d..81c0c99 100644 --- a/dist/bundle.es.js +++ b/dist/bundle.es.js @@ -1120,11 +1120,13 @@ const getSearchQueryString = (query, options = {}) => { if (includeUserOptions) { const claimType = options[SEARCH_OPTIONS.CLAIM_TYPE]; - queryParams.push(`claimType=${claimType}`); + if (claimType) { + queryParams.push(`claimType=${claimType}`); - // If they are only searching for channels, strip out the media info - if (!claimType.includes(SEARCH_OPTIONS.INCLUDE_CHANNELS)) { - queryParams.push(`mediaType=${[SEARCH_OPTIONS.MEDIA_FILE, SEARCH_OPTIONS.MEDIA_AUDIO, SEARCH_OPTIONS.MEDIA_VIDEO, SEARCH_OPTIONS.MEDIA_TEXT, SEARCH_OPTIONS.MEDIA_IMAGE, SEARCH_OPTIONS.MEDIA_APPLICATION].reduce((acc, currentOption) => options[currentOption] ? `${acc}${currentOption},` : acc, '')}`); + // If they are only searching for channels, strip out the media info + if (!claimType.includes(SEARCH_OPTIONS.INCLUDE_CHANNELS)) { + queryParams.push(`mediaType=${[SEARCH_OPTIONS.MEDIA_FILE, SEARCH_OPTIONS.MEDIA_AUDIO, SEARCH_OPTIONS.MEDIA_VIDEO, SEARCH_OPTIONS.MEDIA_TEXT, SEARCH_OPTIONS.MEDIA_IMAGE, SEARCH_OPTIONS.MEDIA_APPLICATION].reduce((acc, currentOption) => options[currentOption] ? `${acc}${currentOption},` : acc, '')}`); + } } } @@ -2395,13 +2397,9 @@ const makeSelectResolvedRecommendedContentForUri = (uri, size) => reselect.creat return; } - const options = { related_to: claim.claim_id, isBackgroundSearch: true }; - if (!isMature) { - options['nsfw'] = false; - } + const options = { related_to: claim.claim_id, size, isBackgroundSearch: false }; const searchQuery = getSearchQueryString(title.replace(/\//, ' '), options); - let results = resolvedResultsByQuery[searchQuery]; if (results) { results = results.filter(result => buildURI({ streamClaimId: result.claimId, streamName: result.name }) !== currentUri); diff --git a/src/redux/selectors/claims.js b/src/redux/selectors/claims.js index 6f67721..4db130a 100644 --- a/src/redux/selectors/claims.js +++ b/src/redux/selectors/claims.js @@ -701,13 +701,9 @@ export const makeSelectResolvedRecommendedContentForUri = (uri: string, size: nu related_to?: string, nsfw?: boolean, isBackgroundSearch?: boolean, - } = { related_to: claim.claim_id, isBackgroundSearch: true }; - if (!isMature) { - options['nsfw'] = false; - } + } = { related_to: claim.claim_id, size, isBackgroundSearch: false }; const searchQuery = getSearchQueryString(title.replace(/\//, ' '), options); - let results = resolvedResultsByQuery[searchQuery]; if (results) { results = results.filter( diff --git a/src/util/query-params.js b/src/util/query-params.js index 80a1d54..bb1d5ec 100644 --- a/src/util/query-params.js +++ b/src/util/query-params.js @@ -48,23 +48,25 @@ export const getSearchQueryString = ( if (includeUserOptions) { const claimType = options[SEARCH_OPTIONS.CLAIM_TYPE]; - queryParams.push(`claimType=${claimType}`); + if (claimType) { + queryParams.push(`claimType=${claimType}`); - // If they are only searching for channels, strip out the media info - if (!claimType.includes(SEARCH_OPTIONS.INCLUDE_CHANNELS)) { - queryParams.push( - `mediaType=${[ - SEARCH_OPTIONS.MEDIA_FILE, - SEARCH_OPTIONS.MEDIA_AUDIO, - SEARCH_OPTIONS.MEDIA_VIDEO, - SEARCH_OPTIONS.MEDIA_TEXT, - SEARCH_OPTIONS.MEDIA_IMAGE, - SEARCH_OPTIONS.MEDIA_APPLICATION, - ].reduce( - (acc, currentOption) => (options[currentOption] ? `${acc}${currentOption},` : acc), - '' - )}` - ); + // If they are only searching for channels, strip out the media info + if (!claimType.includes(SEARCH_OPTIONS.INCLUDE_CHANNELS)) { + queryParams.push( + `mediaType=${[ + SEARCH_OPTIONS.MEDIA_FILE, + SEARCH_OPTIONS.MEDIA_AUDIO, + SEARCH_OPTIONS.MEDIA_VIDEO, + SEARCH_OPTIONS.MEDIA_TEXT, + SEARCH_OPTIONS.MEDIA_IMAGE, + SEARCH_OPTIONS.MEDIA_APPLICATION, + ].reduce( + (acc, currentOption) => (options[currentOption] ? `${acc}${currentOption},` : acc), + '' + )}` + ); + } } }