pass nsfw=false to lighthouse searches

This commit is contained in:
jessop 2020-01-28 17:05:44 -05:00 committed by Sean Yesmunt
parent 0bed38af91
commit 7f0fd02ffc
10 changed files with 41 additions and 16 deletions

View file

@ -3,7 +3,7 @@
"ui/**/*.{js,jsx,scss,json}": ["prettier --write", "git add"], "ui/**/*.{js,jsx,scss,json}": ["prettier --write", "git add"],
"lbrytv/**/*.{js,jsx,scss,json}": ["prettier --write", "git add"], "lbrytv/**/*.{js,jsx,scss,json}": ["prettier --write", "git add"],
"ui/**/*.{js,jsx}": ["eslint", "flow focus-check --color always", "git add"], "ui/**/*.{js,jsx}": ["eslint", "flow focus-check --color always", "git add"],
"lbrytv/**/*.{js,jsx,scss,json}": ["eslint", "git add"] "lbrytv/**/*.{js,jsx,scss}": ["eslint", "git add"]
}, },
"ignore": ["node_modules", "dist", "package-lock.json"] "ignore": ["node_modules", "dist", "package-lock.json"]
} }

View file

@ -31,7 +31,7 @@
"koa-logger": "^3.2.1", "koa-logger": "^3.2.1",
"koa-send": "^5.0.0", "koa-send": "^5.0.0",
"koa-static": "^5.0.0", "koa-static": "^5.0.0",
"lbry-redux": "lbryio/lbry-redux#4491b975cc3e23bf3733272b7c6079a28c1036b3", "lbry-redux": "lbryio/lbry-redux#2faf5293d6986ca043d422b1a6d7b7ac2a7a1406",
"mysql": "^2.17.1" "mysql": "^2.17.1"
}, },
"devDependencies": { "devDependencies": {

View file

@ -3333,9 +3333,9 @@ latest-version@^3.0.0:
dependencies: dependencies:
package-json "^4.0.0" package-json "^4.0.0"
lbry-redux@lbryio/lbry-redux#4491b975cc3e23bf3733272b7c6079a28c1036b3: lbry-redux@lbryio/lbry-redux#2faf5293d6986ca043d422b1a6d7b7ac2a7a1406:
version "0.0.1" version "0.0.1"
resolved "https://codeload.github.com/lbryio/lbry-redux/tar.gz/4491b975cc3e23bf3733272b7c6079a28c1036b3" resolved "https://codeload.github.com/lbryio/lbry-redux/tar.gz/2faf5293d6986ca043d422b1a6d7b7ac2a7a1406"
dependencies: dependencies:
proxy-polyfill "0.1.6" proxy-polyfill "0.1.6"
reselect "^3.0.0" reselect "^3.0.0"

View file

@ -130,7 +130,7 @@
"imagesloaded": "^4.1.4", "imagesloaded": "^4.1.4",
"json-loader": "^0.5.4", "json-loader": "^0.5.4",
"lbry-format": "https://github.com/lbryio/lbry-format.git", "lbry-format": "https://github.com/lbryio/lbry-format.git",
"lbry-redux": "lbryio/lbry-redux#cda1f431b7463aaa74edff5ee9565ca8e935d607", "lbry-redux": "lbryio/lbry-redux#2faf5293d6986ca043d422b1a6d7b7ac2a7a1406",
"lbryinc": "lbryio/lbryinc#6a59102c52673502569d2c43bd4ee58c315fb2e4", "lbryinc": "lbryio/lbryinc#6a59102c52673502569d2c43bd4ee58c315fb2e4",
"lint-staged": "^7.0.2", "lint-staged": "^7.0.2",
"localforage": "^1.7.1", "localforage": "^1.7.1",

View file

@ -1,15 +1,22 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { makeSelectClaimForUri, doSearch, makeSelectRecommendedContentForUri, selectIsSearching } from 'lbry-redux'; import {
makeSelectClaimForUri,
makeSelectClaimIsNsfw,
doSearch,
makeSelectRecommendedContentForUri,
selectIsSearching,
} from 'lbry-redux';
import RecommendedVideos from './view'; import RecommendedVideos from './view';
const select = (state, props) => ({ const select = (state, props) => ({
claim: makeSelectClaimForUri(props.uri)(state), claim: makeSelectClaimForUri(props.uri)(state),
mature: makeSelectClaimIsNsfw(props.uri)(state),
recommendedContent: makeSelectRecommendedContentForUri(props.uri)(state), recommendedContent: makeSelectRecommendedContentForUri(props.uri)(state),
isSearching: selectIsSearching(state), isSearching: selectIsSearching(state),
}); });
const perform = (dispatch, ownProps) => ({ const perform = dispatch => ({
search: query => dispatch(doSearch(query, 20, undefined, true, { related_to: ownProps.claimId })), search: (query, options) => dispatch(doSearch(query, 20, undefined, true, options)),
}); });
export default connect( export default connect(

View file

@ -2,12 +2,19 @@
import React from 'react'; import React from 'react';
import ClaimList from 'component/claimList'; import ClaimList from 'component/claimList';
type Options = {
related_to: string,
nsfw?: boolean,
};
type Props = { type Props = {
uri: string, uri: string,
claim: ?StreamClaim, claim: ?StreamClaim,
claimId: string,
recommendedContent: Array<string>, recommendedContent: Array<string>,
isSearching: boolean, isSearching: boolean,
search: string => void, search: (string, Options) => void,
mature: boolean,
}; };
export default class RecommendedContent extends React.PureComponent<Props> { export default class RecommendedContent extends React.PureComponent<Props> {
@ -34,12 +41,16 @@ export default class RecommendedContent extends React.PureComponent<Props> {
} }
getRecommendedContent() { getRecommendedContent() {
const { claim, search } = this.props; const { claim, search, mature, claimId } = this.props;
if (claim && claim.value && claim.value) { if (claim && claim.value && claim.value) {
const options: Options = { related_to: claimId };
if (claim && !mature) {
options['nsfw'] = false;
}
const { title } = claim.value; const { title } = claim.value;
if (title) { if (title && options) {
search(title); search(title, options);
this.didSearch = true; this.didSearch = true;
} }
} }

View file

@ -26,6 +26,7 @@ const select = (state, props) => ({
channelIsBlocked: selectChannelIsBlocked(props.uri)(state), channelIsBlocked: selectChannelIsBlocked(props.uri)(state),
blackListedOutpoints: selectBlackListedOutpoints(state), blackListedOutpoints: selectBlackListedOutpoints(state),
supportOption: makeSelectClientSetting(settings.SUPPORT_OPTION)(state), supportOption: makeSelectClientSetting(settings.SUPPORT_OPTION)(state),
showMature: makeSelectClientSetting(settings.SHOW_MATURE)(state),
subCount: makeSelectSubCountForUri(props.uri)(state), subCount: makeSelectSubCountForUri(props.uri)(state),
}); });

View file

@ -52,6 +52,7 @@ type Props = {
supportOption: boolean, supportOption: boolean,
fetchSubCount: string => void, fetchSubCount: string => void,
subCount: number, subCount: number,
showMature: boolean,
}; };
function ChannelPage(props: Props) { function ChannelPage(props: Props) {
@ -70,6 +71,7 @@ function ChannelPage(props: Props) {
blackListedOutpoints, blackListedOutpoints,
openModal, openModal,
supportOption, supportOption,
showMature,
fetchSubCount, fetchSubCount,
subCount, subCount,
} = props; } = props;
@ -126,7 +128,11 @@ function ChannelPage(props: Props) {
// In order to display original search results, search results must be set to null. A query of '' should display original results. // In order to display original search results, search results must be set to null. A query of '' should display original results.
return setSearchResults(null); return setSearchResults(null);
} else { } else {
getResults(`${LIGHTHOUSE_URL}?s=${encodeURIComponent(searchQuery)}&channel_id=${encodeURIComponent(claimId)}`); getResults(
`${LIGHTHOUSE_URL}?s=${encodeURIComponent(searchQuery)}&channel_id=${encodeURIComponent(claimId)}${
!showMature ? '&nsfw=false' : ''
}`
);
} }
}, DEBOUNCE_WAIT_DURATION_MS); }, DEBOUNCE_WAIT_DURATION_MS);
return () => clearTimeout(timer); return () => clearTimeout(timer);

View file

@ -7083,9 +7083,9 @@ lazy-val@^1.0.4:
yargs "^13.2.2" yargs "^13.2.2"
zstd-codec "^0.1.1" zstd-codec "^0.1.1"
lbry-redux@lbryio/lbry-redux#cda1f431b7463aaa74edff5ee9565ca8e935d607: lbry-redux@lbryio/lbry-redux#2faf5293d6986ca043d422b1a6d7b7ac2a7a1406:
version "0.0.1" version "0.0.1"
resolved "https://codeload.github.com/lbryio/lbry-redux/tar.gz/cda1f431b7463aaa74edff5ee9565ca8e935d607" resolved "https://codeload.github.com/lbryio/lbry-redux/tar.gz/2faf5293d6986ca043d422b1a6d7b7ac2a7a1406"
dependencies: dependencies:
proxy-polyfill "0.1.6" proxy-polyfill "0.1.6"
reselect "^3.0.0" reselect "^3.0.0"