Feat block nsfw on search #3586
10 changed files with 49 additions and 22 deletions
|
@ -31,7 +31,7 @@
|
|||
"koa-logger": "^3.2.1",
|
||||
"koa-send": "^5.0.0",
|
||||
"koa-static": "^5.0.0",
|
||||
"lbry-redux": "lbryio/lbry-redux#71e85536dbe397df98a47a3c4b4311760b2e7419",
|
||||
"lbry-redux": "lbryio/lbry-redux#87ae7faf1c1d5ffa86feb578899596f6ea2a5fd9",
|
||||
"mysql": "^2.17.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
|
|
@ -3333,9 +3333,9 @@ latest-version@^3.0.0:
|
|||
dependencies:
|
||||
package-json "^4.0.0"
|
||||
|
||||
lbry-redux@lbryio/lbry-redux#71e85536dbe397df98a47a3c4b4311760b2e7419:
|
||||
lbry-redux@lbryio/lbry-redux#87ae7faf1c1d5ffa86feb578899596f6ea2a5fd9:
|
||||
version "0.0.1"
|
||||
resolved "https://codeload.github.com/lbryio/lbry-redux/tar.gz/71e85536dbe397df98a47a3c4b4311760b2e7419"
|
||||
resolved "https://codeload.github.com/lbryio/lbry-redux/tar.gz/87ae7faf1c1d5ffa86feb578899596f6ea2a5fd9"
|
||||
dependencies:
|
||||
proxy-polyfill "0.1.6"
|
||||
reselect "^3.0.0"
|
||||
|
|
|
@ -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#bfbaa0dbdd2c1b2b340c0760d0d97c99f3cefb02",
|
||||
"lbry-redux": "lbryio/lbry-redux#87ae7faf1c1d5ffa86feb578899596f6ea2a5fd9",
|
||||
"lbryinc": "lbryio/lbryinc#6a59102c52673502569d2c43bd4ee58c315fb2e4",
|
||||
"lint-staged": "^7.0.2",
|
||||
"localforage": "^1.7.1",
|
||||
|
|
|
@ -919,5 +919,7 @@
|
|||
"Your wallet": "Your wallet",
|
||||
"Publish a file, or create a channel": "Publish a file, or create a channel",
|
||||
"Your account": "Your account",
|
||||
"Channel profile picture": "Channel profile picture"
|
||||
"Channel profile picture": "Channel profile picture",
|
||||
"refreshing the app": "refreshing the app",
|
||||
"Follower": "Follower"
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ const select = (state, props) => ({
|
|||
});
|
||||
|
||||
const perform = dispatch => ({
|
||||
search: (query, options) => dispatch(doSearch(query, 20, undefined, true, options)),
|
||||
search: (query, options) => dispatch(doSearch(query, options)),
|
||||
});
|
||||
|
||||
export default connect(
|
||||
|
|
|
@ -44,7 +44,7 @@ export default class RecommendedContent extends React.PureComponent<Props> {
|
|||
const { claim, search, mature, claimId } = this.props;
|
||||
|
||||
if (claim && claim.value && claim.value) {
|
||||
const options: Options = { related_to: claimId };
|
||||
const options: Options = { size: 20, related_to: claimId, isBackgroundSearch: true };
|
||||
if (claim && !mature) {
|
||||
options['nsfw'] = false;
|
||||
}
|
||||
|
|
|
@ -10,10 +10,13 @@ const select = state => ({
|
|||
query: makeSelectQueryWithOptions()(state),
|
||||
});
|
||||
|
||||
const perform = dispatch => ({
|
||||
setSearchOption: (option, value) => dispatch(doUpdateSearchOptions({ [option]: value })),
|
||||
toggleSearchExpanded: () => dispatch(doToggleSearchExpanded()),
|
||||
});
|
||||
const perform = (dispatch, ownProps) => {
|
||||
const additionalOptions = ownProps.additionalOptions || {};
|
||||
return {
|
||||
setSearchOption: (option, value) => dispatch(doUpdateSearchOptions({ [option]: value }, additionalOptions)),
|
||||
toggleSearchExpanded: () => dispatch(doToggleSearchExpanded()),
|
||||
};
|
||||
};
|
||||
|
||||
export default connect(
|
||||
select,
|
||||
|
|
|
@ -1,15 +1,27 @@
|
|||
import { connect } from 'react-redux';
|
||||
import * as SETTINGS from 'constants/settings';
|
||||
import { doSearch, selectIsSearching, makeSelectSearchUris, makeSelectQueryWithOptions, doToast } from 'lbry-redux';
|
||||
import { makeSelectClientSetting } from 'redux/selectors/settings';
|
||||
import analytics from 'analytics';
|
||||
import SearchPage from './view';
|
||||
|
||||
const select = state => ({
|
||||
isSearching: selectIsSearching(state),
|
||||
uris: makeSelectSearchUris(makeSelectQueryWithOptions()(state))(state),
|
||||
});
|
||||
const select = state => {
|
||||
const showMature = makeSelectClientSetting(SETTINGS.SHOW_MATURE)(state);
|
||||
const query = makeSelectQueryWithOptions(
|
||||
null,
|
||||
showMature === false ? { nsfw: false, isBackgroundSearch: false } : { isBackgroundSearch: false }
|
||||
)(state);
|
||||
const uris = makeSelectSearchUris(query)(state);
|
||||
|
||||
return {
|
||||
isSearching: selectIsSearching(state),
|
||||
showNsfw: makeSelectClientSetting(SETTINGS.SHOW_MATURE)(state),
|
||||
uris: uris,
|
||||
};
|
||||
};
|
||||
|
||||
const perform = dispatch => ({
|
||||
search: query => dispatch(doSearch(query)),
|
||||
search: (query, options) => dispatch(doSearch(query, options)),
|
||||
onFeedbackPositive: query => {
|
||||
analytics.apiSearchFeedback(query, 1);
|
||||
dispatch(
|
||||
|
|
|
@ -9,19 +9,29 @@ import SearchOptions from 'component/searchOptions';
|
|||
import Button from 'component/button';
|
||||
import ClaimUri from 'component/claimUri';
|
||||
|
||||
type AdditionalOptions = {
|
||||
isBackgroundSearch: boolean,
|
||||
nsfw?: boolean,
|
||||
};
|
||||
|
||||
type Props = {
|
||||
search: string => void,
|
||||
search: (string, AdditionalOptions) => void,
|
||||
isSearching: boolean,
|
||||
location: UrlLocation,
|
||||
uris: Array<string>,
|
||||
onFeedbackNegative: string => void,
|
||||
onFeedbackPositive: string => void,
|
||||
showNsfw: boolean,
|
||||
};
|
||||
|
||||
export default function SearchPage(props: Props) {
|
||||
const { search, uris, onFeedbackPositive, onFeedbackNegative, location, isSearching } = props;
|
||||
const { search, uris, onFeedbackPositive, onFeedbackNegative, location, isSearching, showNsfw } = props;
|
||||
const urlParams = new URLSearchParams(location.search);
|
||||
const urlQuery = urlParams.get('q');
|
||||
const additionalOptions: AdditionalOptions = { isBackgroundSearch: false };
|
||||
if (!showNsfw) {
|
||||
additionalOptions['nsfw'] = false;
|
||||
}
|
||||
|
||||
let normalizedUri;
|
||||
let isUriValid;
|
||||
|
@ -42,7 +52,7 @@ export default function SearchPage(props: Props) {
|
|||
|
||||
useEffect(() => {
|
||||
if (urlQuery) {
|
||||
search(urlQuery);
|
||||
search(urlQuery, additionalOptions);
|
||||
}
|
||||
}, [search, urlQuery]);
|
||||
|
||||
|
@ -63,7 +73,7 @@ export default function SearchPage(props: Props) {
|
|||
<ClaimList
|
||||
uris={uris}
|
||||
loading={isSearching}
|
||||
header={<SearchOptions />}
|
||||
header={<SearchOptions additionalOptions={additionalOptions} />}
|
||||
headerAltControls={
|
||||
<Fragment>
|
||||
<span>{__('Find what you were looking for?')}</span>
|
||||
|
|
|
@ -7277,9 +7277,9 @@ lazy-val@^1.0.4:
|
|||
yargs "^13.2.2"
|
||||
zstd-codec "^0.1.1"
|
||||
|
||||
lbry-redux@lbryio/lbry-redux#bfbaa0dbdd2c1b2b340c0760d0d97c99f3cefb02:
|
||||
lbry-redux@lbryio/lbry-redux#87ae7faf1c1d5ffa86feb578899596f6ea2a5fd9:
|
||||
version "0.0.1"
|
||||
resolved "https://codeload.github.com/lbryio/lbry-redux/tar.gz/bfbaa0dbdd2c1b2b340c0760d0d97c99f3cefb02"
|
||||
resolved "https://codeload.github.com/lbryio/lbry-redux/tar.gz/87ae7faf1c1d5ffa86feb578899596f6ea2a5fd9"
|
||||
dependencies:
|
||||
proxy-polyfill "0.1.6"
|
||||
reselect "^3.0.0"
|
||||
|
|
Loading…
Reference in a new issue