From 7f0fd02ffc51bef4ff8eaef5be70475b6b63cdcd Mon Sep 17 00:00:00 2001 From: jessop Date: Tue, 28 Jan 2020 17:05:44 -0500 Subject: [PATCH] pass nsfw=false to lighthouse searches --- .lintstagedrc.json | 2 +- lbrytv/package.json | 2 +- lbrytv/yarn.lock | 4 ++-- package.json | 2 +- static/app-strings.json | 2 +- ui/component/recommendedContent/index.js | 13 ++++++++++--- ui/component/recommendedContent/view.jsx | 19 +++++++++++++++---- ui/page/channel/index.js | 1 + ui/page/channel/view.jsx | 8 +++++++- yarn.lock | 4 ++-- 10 files changed, 41 insertions(+), 16 deletions(-) diff --git a/.lintstagedrc.json b/.lintstagedrc.json index 6bafc1f42..9333f0b94 100644 --- a/.lintstagedrc.json +++ b/.lintstagedrc.json @@ -3,7 +3,7 @@ "ui/**/*.{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"], - "lbrytv/**/*.{js,jsx,scss,json}": ["eslint", "git add"] + "lbrytv/**/*.{js,jsx,scss}": ["eslint", "git add"] }, "ignore": ["node_modules", "dist", "package-lock.json"] } diff --git a/lbrytv/package.json b/lbrytv/package.json index 20af7da15..73bc2c0e0 100644 --- a/lbrytv/package.json +++ b/lbrytv/package.json @@ -31,7 +31,7 @@ "koa-logger": "^3.2.1", "koa-send": "^5.0.0", "koa-static": "^5.0.0", - "lbry-redux": "lbryio/lbry-redux#4491b975cc3e23bf3733272b7c6079a28c1036b3", + "lbry-redux": "lbryio/lbry-redux#2faf5293d6986ca043d422b1a6d7b7ac2a7a1406", "mysql": "^2.17.1" }, "devDependencies": { diff --git a/lbrytv/yarn.lock b/lbrytv/yarn.lock index 6f07e70de..413dbe49c 100644 --- a/lbrytv/yarn.lock +++ b/lbrytv/yarn.lock @@ -3333,9 +3333,9 @@ latest-version@^3.0.0: dependencies: package-json "^4.0.0" -lbry-redux@lbryio/lbry-redux#4491b975cc3e23bf3733272b7c6079a28c1036b3: +lbry-redux@lbryio/lbry-redux#2faf5293d6986ca043d422b1a6d7b7ac2a7a1406: 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: proxy-polyfill "0.1.6" reselect "^3.0.0" diff --git a/package.json b/package.json index 2da67134d..6df607cba 100644 --- a/package.json +++ b/package.json @@ -130,7 +130,7 @@ "imagesloaded": "^4.1.4", "json-loader": "^0.5.4", "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", "lint-staged": "^7.0.2", "localforage": "^1.7.1", diff --git a/static/app-strings.json b/static/app-strings.json index d92cf64f6..6e95ce1f4 100644 --- a/static/app-strings.json +++ b/static/app-strings.json @@ -916,4 +916,4 @@ "You deposited %amount% LBC as a support!": "You deposited %amount% LBC as a support!", "LBRY Link": "LBRY Link", "Publish to %uri%": "Publish to %uri%" -} \ No newline at end of file +} diff --git a/ui/component/recommendedContent/index.js b/ui/component/recommendedContent/index.js index 8caf4d23f..54d1e2101 100644 --- a/ui/component/recommendedContent/index.js +++ b/ui/component/recommendedContent/index.js @@ -1,15 +1,22 @@ 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'; const select = (state, props) => ({ claim: makeSelectClaimForUri(props.uri)(state), + mature: makeSelectClaimIsNsfw(props.uri)(state), recommendedContent: makeSelectRecommendedContentForUri(props.uri)(state), isSearching: selectIsSearching(state), }); -const perform = (dispatch, ownProps) => ({ - search: query => dispatch(doSearch(query, 20, undefined, true, { related_to: ownProps.claimId })), +const perform = dispatch => ({ + search: (query, options) => dispatch(doSearch(query, 20, undefined, true, options)), }); export default connect( diff --git a/ui/component/recommendedContent/view.jsx b/ui/component/recommendedContent/view.jsx index 9a0877b2a..cd73da06b 100644 --- a/ui/component/recommendedContent/view.jsx +++ b/ui/component/recommendedContent/view.jsx @@ -2,12 +2,19 @@ import React from 'react'; import ClaimList from 'component/claimList'; +type Options = { + related_to: string, + nsfw?: boolean, +}; + type Props = { uri: string, claim: ?StreamClaim, + claimId: string, recommendedContent: Array, isSearching: boolean, - search: string => void, + search: (string, Options) => void, + mature: boolean, }; export default class RecommendedContent extends React.PureComponent { @@ -34,12 +41,16 @@ export default class RecommendedContent extends React.PureComponent { } getRecommendedContent() { - const { claim, search } = this.props; + const { claim, search, mature, claimId } = this.props; if (claim && claim.value && claim.value) { + const options: Options = { related_to: claimId }; + if (claim && !mature) { + options['nsfw'] = false; + } const { title } = claim.value; - if (title) { - search(title); + if (title && options) { + search(title, options); this.didSearch = true; } } diff --git a/ui/page/channel/index.js b/ui/page/channel/index.js index ea4041756..da42cdfc4 100644 --- a/ui/page/channel/index.js +++ b/ui/page/channel/index.js @@ -26,6 +26,7 @@ const select = (state, props) => ({ channelIsBlocked: selectChannelIsBlocked(props.uri)(state), blackListedOutpoints: selectBlackListedOutpoints(state), supportOption: makeSelectClientSetting(settings.SUPPORT_OPTION)(state), + showMature: makeSelectClientSetting(settings.SHOW_MATURE)(state), subCount: makeSelectSubCountForUri(props.uri)(state), }); diff --git a/ui/page/channel/view.jsx b/ui/page/channel/view.jsx index 786e6b73f..a5e0bb250 100644 --- a/ui/page/channel/view.jsx +++ b/ui/page/channel/view.jsx @@ -52,6 +52,7 @@ type Props = { supportOption: boolean, fetchSubCount: string => void, subCount: number, + showMature: boolean, }; function ChannelPage(props: Props) { @@ -70,6 +71,7 @@ function ChannelPage(props: Props) { blackListedOutpoints, openModal, supportOption, + showMature, fetchSubCount, subCount, } = 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. return setSearchResults(null); } 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); return () => clearTimeout(timer); diff --git a/yarn.lock b/yarn.lock index 873a7d349..101c3bbc1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7083,9 +7083,9 @@ lazy-val@^1.0.4: yargs "^13.2.2" zstd-codec "^0.1.1" -lbry-redux@lbryio/lbry-redux#cda1f431b7463aaa74edff5ee9565ca8e935d607: +lbry-redux@lbryio/lbry-redux#2faf5293d6986ca043d422b1a6d7b7ac2a7a1406: 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: proxy-polyfill "0.1.6" reselect "^3.0.0"