blocks mature content from search when appropriate
wip bump lbry-redux refactor search selector bump redux
This commit is contained in:
parent
d2240d3df5
commit
c7351551da
7 changed files with 44 additions and 17 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#b4b50b610d9465b62ce38d962c354e151d6d4487",
|
||||
"mysql": "^2.17.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Add table
Reference in a new issue