use show mature selector (#5803)

This commit is contained in:
jessopb 2021-03-31 16:55:26 -04:00 committed by GitHub
parent e0e277f27d
commit 9cd86be04f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 41 additions and 37 deletions

View file

@ -12,7 +12,7 @@ import {
import { makeSelectChannelIsMuted } from 'redux/selectors/blocked'; import { makeSelectChannelIsMuted } from 'redux/selectors/blocked';
import { withRouter } from 'react-router'; import { withRouter } from 'react-router';
import { selectUserVerifiedEmail } from 'redux/selectors/user'; import { selectUserVerifiedEmail } from 'redux/selectors/user';
import { makeSelectClientSetting } from 'redux/selectors/settings'; import { makeSelectClientSetting, selectShowMatureContent } from 'redux/selectors/settings';
import ChannelPage from './view'; import ChannelPage from './view';
@ -28,7 +28,7 @@ const select = (state, props) => {
channelIsBlocked: makeSelectChannelIsMuted(props.uri)(state), channelIsBlocked: makeSelectChannelIsMuted(props.uri)(state),
claim: props.uri && makeSelectClaimForUri(props.uri)(state), claim: props.uri && makeSelectClaimForUri(props.uri)(state),
isAuthenticated: selectUserVerifiedEmail(state), isAuthenticated: selectUserVerifiedEmail(state),
showMature: makeSelectClientSetting(SETTINGS.SHOW_MATURE)(state), showMature: selectShowMatureContent(state),
tileLayout: makeSelectClientSetting(SETTINGS.TILE_LAYOUT)(state), tileLayout: makeSelectClientSetting(SETTINGS.TILE_LAYOUT)(state),
}; };
}; };

View file

@ -9,7 +9,7 @@ import {
import { selectFollowedTags } from 'redux/selectors/tags'; import { selectFollowedTags } from 'redux/selectors/tags';
import { selectMutedChannels } from 'redux/selectors/blocked'; import { selectMutedChannels } from 'redux/selectors/blocked';
import { doToggleTagFollowDesktop } from 'redux/actions/tags'; import { doToggleTagFollowDesktop } from 'redux/actions/tags';
import { makeSelectClientSetting, selectLanguage } from 'redux/selectors/settings'; import { makeSelectClientSetting, selectShowMatureContent, selectLanguage } from 'redux/selectors/settings';
import { selectModerationBlockList } from 'redux/selectors/comments'; import { selectModerationBlockList } from 'redux/selectors/comments';
import ClaimListDiscover from './view'; import ClaimListDiscover from './view';
@ -18,7 +18,7 @@ const select = (state) => ({
claimSearchByQuery: selectClaimSearchByQuery(state), claimSearchByQuery: selectClaimSearchByQuery(state),
claimSearchByQueryLastPageReached: selectClaimSearchByQueryLastPageReached(state), claimSearchByQueryLastPageReached: selectClaimSearchByQueryLastPageReached(state),
loading: selectFetchingClaimSearch(state), loading: selectFetchingClaimSearch(state),
showNsfw: makeSelectClientSetting(SETTINGS.SHOW_MATURE)(state), showNsfw: selectShowMatureContent(state),
hideReposts: makeSelectClientSetting(SETTINGS.HIDE_REPOSTS)(state), hideReposts: makeSelectClientSetting(SETTINGS.HIDE_REPOSTS)(state),
languageSetting: selectLanguage(state), languageSetting: selectLanguage(state),
mutedUris: selectMutedChannels(state), mutedUris: selectMutedChannels(state),

View file

@ -2,14 +2,14 @@ import { connect } from 'react-redux';
import { selectFetchingClaimSearch, SETTINGS } from 'lbry-redux'; import { selectFetchingClaimSearch, SETTINGS } from 'lbry-redux';
import { selectFollowedTags } from 'redux/selectors/tags'; import { selectFollowedTags } from 'redux/selectors/tags';
import { doToggleTagFollowDesktop } from 'redux/actions/tags'; import { doToggleTagFollowDesktop } from 'redux/actions/tags';
import { makeSelectClientSetting, selectLanguage } from 'redux/selectors/settings'; import { makeSelectClientSetting, selectShowMatureContent, selectLanguage } from 'redux/selectors/settings';
import { doSetClientSetting } from 'redux/actions/settings'; import { doSetClientSetting } from 'redux/actions/settings';
import ClaimListHeader from './view'; import ClaimListHeader from './view';
const select = state => ({ const select = (state) => ({
followedTags: selectFollowedTags(state), followedTags: selectFollowedTags(state),
loading: selectFetchingClaimSearch(state), loading: selectFetchingClaimSearch(state),
showNsfw: makeSelectClientSetting(SETTINGS.SHOW_MATURE)(state), showNsfw: selectShowMatureContent(state),
searchInLanguage: makeSelectClientSetting(SETTINGS.SEARCH_IN_LANGUAGE)(state), searchInLanguage: makeSelectClientSetting(SETTINGS.SEARCH_IN_LANGUAGE)(state),
languageSetting: selectLanguage(state), languageSetting: selectLanguage(state),
}); });

View file

@ -1,13 +1,13 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { doClaimSearch, selectClaimSearchByQuery, selectFetchingClaimSearchByQuery, SETTINGS } from 'lbry-redux'; import { doClaimSearch, selectClaimSearchByQuery, selectFetchingClaimSearchByQuery, SETTINGS } from 'lbry-redux';
import { doToggleTagFollowDesktop } from 'redux/actions/tags'; import { doToggleTagFollowDesktop } from 'redux/actions/tags';
import { makeSelectClientSetting } from 'redux/selectors/settings'; import { makeSelectClientSetting, selectShowMatureContent } from 'redux/selectors/settings';
import ClaimListDiscover from './view'; import ClaimListDiscover from './view';
const select = (state) => ({ const select = (state) => ({
claimSearchByQuery: selectClaimSearchByQuery(state), claimSearchByQuery: selectClaimSearchByQuery(state),
fetchingClaimSearchByQuery: selectFetchingClaimSearchByQuery(state), fetchingClaimSearchByQuery: selectFetchingClaimSearchByQuery(state),
showNsfw: makeSelectClientSetting(SETTINGS.SHOW_MATURE)(state), showNsfw: selectShowMatureContent(state),
hideReposts: makeSelectClientSetting(SETTINGS.HIDE_REPOSTS)(state), hideReposts: makeSelectClientSetting(SETTINGS.HIDE_REPOSTS)(state),
}); });

View file

@ -1,28 +1,28 @@
import * as MODALS from 'constants/modal_types'; import * as MODALS from 'constants/modal_types';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { selectLanguage, makeSelectClientSetting } from 'redux/selectors/settings'; import { selectLanguage, selectShowMatureContent } from 'redux/selectors/settings';
import { doToast } from 'redux/actions/notifications'; import { doToast } from 'redux/actions/notifications';
import { doSearch } from 'redux/actions/search'; import { doSearch } from 'redux/actions/search';
import { doOpenModal, doHideModal } from 'redux/actions/app'; import { doOpenModal, doHideModal } from 'redux/actions/app';
import { withRouter } from 'react-router'; import { withRouter } from 'react-router';
import { doResolveUris, SETTINGS } from 'lbry-redux'; import { doResolveUris } from 'lbry-redux';
import analytics from 'analytics'; import analytics from 'analytics';
import Wunderbar from './view'; import Wunderbar from './view';
const select = (state, props) => ({ const select = (state, props) => ({
language: selectLanguage(state), language: selectLanguage(state),
showMature: makeSelectClientSetting(SETTINGS.SHOW_MATURE)(state), showMature: selectShowMatureContent(state),
}); });
const perform = (dispatch, ownProps) => ({ const perform = (dispatch, ownProps) => ({
doResolveUris: uris => dispatch(doResolveUris(uris)), doResolveUris: (uris) => dispatch(doResolveUris(uris)),
doSearch: (query, options) => dispatch(doSearch(query, options)), doSearch: (query, options) => dispatch(doSearch(query, options)),
navigateToSearchPage: query => { navigateToSearchPage: (query) => {
let encodedQuery = encodeURIComponent(query); let encodedQuery = encodeURIComponent(query);
ownProps.history.push({ pathname: `/$/search`, search: `?q=${encodedQuery}` }); ownProps.history.push({ pathname: `/$/search`, search: `?q=${encodedQuery}` });
analytics.apiLogSearch(); analytics.apiLogSearch();
}, },
doShowSnackBar: message => dispatch(doToast({ isError: true, message })), doShowSnackBar: (message) => dispatch(doToast({ isError: true, message })),
doOpenMobileSearch: () => dispatch(doOpenModal(MODALS.MOBILE_SEARCH)), doOpenMobileSearch: () => dispatch(doOpenModal(MODALS.MOBILE_SEARCH)),
doCloseMobileSearch: () => dispatch(doHideModal()), doCloseMobileSearch: () => dispatch(doHideModal()),
}); });

View file

@ -1,17 +1,16 @@
import * as SETTINGS from 'constants/settings';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { selectFollowedTags } from 'redux/selectors/tags'; import { selectFollowedTags } from 'redux/selectors/tags';
import { selectUserVerifiedEmail } from 'redux/selectors/user'; import { selectUserVerifiedEmail } from 'redux/selectors/user';
import { selectSubscriptions } from 'redux/selectors/subscriptions'; import { selectSubscriptions } from 'redux/selectors/subscriptions';
import { makeSelectClientSetting, selectHomepageData } from 'redux/selectors/settings'; import { selectShowMatureContent, selectHomepageData } from 'redux/selectors/settings';
import DiscoverPage from './view'; import DiscoverPage from './view';
const select = state => ({ const select = (state) => ({
followedTags: selectFollowedTags(state), followedTags: selectFollowedTags(state),
subscribedChannels: selectSubscriptions(state), subscribedChannels: selectSubscriptions(state),
authenticated: selectUserVerifiedEmail(state), authenticated: selectUserVerifiedEmail(state),
showNsfw: makeSelectClientSetting(SETTINGS.SHOW_MATURE)(state), showNsfw: selectShowMatureContent(state),
homepageData: selectHomepageData(state), homepageData: selectHomepageData(state),
}); });

View file

@ -1,5 +1,5 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { doToast, SETTINGS } from 'lbry-redux'; import { doToast } from 'lbry-redux';
import { withRouter } from 'react-router'; import { withRouter } from 'react-router';
import { doSearch } from 'redux/actions/search'; import { doSearch } from 'redux/actions/search';
import { import {
@ -8,13 +8,13 @@ import {
makeSelectQueryWithOptions, makeSelectQueryWithOptions,
selectSearchOptions, selectSearchOptions,
} from 'redux/selectors/search'; } from 'redux/selectors/search';
import { makeSelectClientSetting } from 'redux/selectors/settings'; import { selectShowMatureContent } from 'redux/selectors/settings';
import { selectUserVerifiedEmail } from 'redux/selectors/user'; import { selectUserVerifiedEmail } from 'redux/selectors/user';
import analytics from 'analytics'; import analytics from 'analytics';
import SearchPage from './view'; import SearchPage from './view';
const select = (state, props) => { const select = (state, props) => {
const showMature = makeSelectClientSetting(SETTINGS.SHOW_MATURE)(state); const showMature = selectShowMatureContent(state);
const urlParams = new URLSearchParams(props.location.search); const urlParams = new URLSearchParams(props.location.search);
let urlQuery = urlParams.get('q') || null; let urlQuery = urlParams.get('q') || null;
if (urlQuery) { if (urlQuery) {
@ -29,16 +29,16 @@ const select = (state, props) => {
return { return {
isSearching: selectIsSearching(state), isSearching: selectIsSearching(state),
showNsfw: makeSelectClientSetting(SETTINGS.SHOW_MATURE)(state), showNsfw: showMature,
uris: uris, uris: uris,
isAuthenticated: selectUserVerifiedEmail(state), isAuthenticated: selectUserVerifiedEmail(state),
searchOptions: selectSearchOptions(state), searchOptions: selectSearchOptions(state),
}; };
}; };
const perform = dispatch => ({ const perform = (dispatch) => ({
search: (query, options) => dispatch(doSearch(query, options)), search: (query, options) => dispatch(doSearch(query, options)),
onFeedbackPositive: query => { onFeedbackPositive: (query) => {
analytics.apiSearchFeedback(query, 1); analytics.apiSearchFeedback(query, 1);
dispatch( dispatch(
doToast({ doToast({
@ -46,7 +46,7 @@ const perform = dispatch => ({
}) })
); );
}, },
onFeedbackNegative: query => { onFeedbackNegative: (query) => {
analytics.apiSearchFeedback(query, 0); analytics.apiSearchFeedback(query, 0);
dispatch( dispatch(
doToast({ doToast({

View file

@ -10,7 +10,12 @@ import {
doExitSettingsPage, doExitSettingsPage,
} from 'redux/actions/settings'; } from 'redux/actions/settings';
import { doSetPlayingUri } from 'redux/actions/content'; import { doSetPlayingUri } from 'redux/actions/content';
import { makeSelectClientSetting, selectDaemonSettings, selectLanguage } from 'redux/selectors/settings'; import {
makeSelectClientSetting,
selectDaemonSettings,
selectLanguage,
selectShowMatureContent,
} from 'redux/selectors/settings';
import { doWalletStatus, selectWalletIsEncrypted, SETTINGS } from 'lbry-redux'; import { doWalletStatus, selectWalletIsEncrypted, SETTINGS } from 'lbry-redux';
import SettingsPage from './view'; import SettingsPage from './view';
import { selectUserVerifiedEmail } from 'redux/selectors/user'; import { selectUserVerifiedEmail } from 'redux/selectors/user';
@ -19,7 +24,7 @@ const select = (state) => ({
daemonSettings: selectDaemonSettings(state), daemonSettings: selectDaemonSettings(state),
allowAnalytics: selectAllowAnalytics(state), allowAnalytics: selectAllowAnalytics(state),
isAuthenticated: selectUserVerifiedEmail(state), isAuthenticated: selectUserVerifiedEmail(state),
showNsfw: makeSelectClientSetting(SETTINGS.SHOW_MATURE)(state), showNsfw: selectShowMatureContent(state),
currentTheme: makeSelectClientSetting(SETTINGS.THEME)(state), currentTheme: makeSelectClientSetting(SETTINGS.THEME)(state),
themes: makeSelectClientSetting(SETTINGS.THEMES)(state), themes: makeSelectClientSetting(SETTINGS.THEMES)(state),
automaticDarkModeEnabled: makeSelectClientSetting(SETTINGS.AUTOMATIC_DARK_MODE_ENABLED)(state), automaticDarkModeEnabled: makeSelectClientSetting(SETTINGS.AUTOMATIC_DARK_MODE_ENABLED)(state),

View file

@ -1,8 +1,7 @@
// @flow // @flow
import * as SETTINGS from 'constants/settings';
import { createSelector } from 'reselect'; import { createSelector } from 'reselect';
import { selectMutedChannels } from 'redux/selectors/blocked'; import { selectMutedChannels } from 'redux/selectors/blocked';
import { makeSelectClientSetting } from 'redux/selectors/settings'; import { selectShowMatureContent } from 'redux/selectors/settings';
import { selectBlacklistedOutpointMap, selectFilteredOutpointMap } from 'lbryinc'; import { selectBlacklistedOutpointMap, selectFilteredOutpointMap } from 'lbryinc';
import { selectClaimsById, isClaimNsfw, selectMyActiveClaims } from 'lbry-redux'; import { selectClaimsById, isClaimNsfw, selectMyActiveClaims } from 'lbry-redux';
@ -132,7 +131,7 @@ export const makeSelectCommentsForUri = (uri: string) =>
selectMutedChannels, selectMutedChannels,
selectBlacklistedOutpointMap, selectBlacklistedOutpointMap,
selectFilteredOutpointMap, selectFilteredOutpointMap,
makeSelectClientSetting(SETTINGS.SHOW_MATURE), selectShowMatureContent,
(byClaimId, byUri, claimsById, myClaims, blockedChannels, blacklistedMap, filteredMap, showMatureContent) => { (byClaimId, byUri, claimsById, myClaims, blockedChannels, blacklistedMap, filteredMap, showMatureContent) => {
const claimId = byUri[uri]; const claimId = byUri[uri];
const comments = byClaimId && byClaimId[claimId]; const comments = byClaimId && byClaimId[claimId];
@ -183,7 +182,7 @@ export const makeSelectTopLevelCommentsForUri = (uri: string) =>
selectMutedChannels, selectMutedChannels,
selectBlacklistedOutpointMap, selectBlacklistedOutpointMap,
selectFilteredOutpointMap, selectFilteredOutpointMap,
makeSelectClientSetting(SETTINGS.SHOW_MATURE), selectShowMatureContent,
(byClaimId, byUri, claimsById, myClaims, blockedChannels, blacklistedMap, filteredMap, showMatureContent) => { (byClaimId, byUri, claimsById, myClaims, blockedChannels, blacklistedMap, filteredMap, showMatureContent) => {
const claimId = byUri[uri]; const claimId = byUri[uri];
const comments = byClaimId && byClaimId[claimId]; const comments = byClaimId && byClaimId[claimId];
@ -233,7 +232,7 @@ export const makeSelectRepliesForParentId = (id: string) =>
selectMutedChannels, selectMutedChannels,
selectBlacklistedOutpointMap, selectBlacklistedOutpointMap,
selectFilteredOutpointMap, selectFilteredOutpointMap,
makeSelectClientSetting(SETTINGS.SHOW_MATURE), selectShowMatureContent,
(state, commentsById, claimsById, myClaims, blockedChannels, blacklistedMap, filteredMap, showMatureContent) => { (state, commentsById, claimsById, myClaims, blockedChannels, blacklistedMap, filteredMap, showMatureContent) => {
// const claimId = byUri[uri]; // just parentId (id) // const claimId = byUri[uri]; // just parentId (id)
const replyIdsByParentId = state.repliesByParentId; const replyIdsByParentId = state.repliesByParentId;

View file

@ -1,12 +1,11 @@
// @flow // @flow
import { getSearchQueryString } from 'util/query-params'; import { getSearchQueryString } from 'util/query-params';
import { makeSelectClientSetting } from 'redux/selectors/settings'; import { selectShowMatureContent } from 'redux/selectors/settings';
import { import {
parseURI, parseURI,
makeSelectClaimForUri, makeSelectClaimForUri,
makeSelectClaimIsNsfw, makeSelectClaimIsNsfw,
buildURI, buildURI,
SETTINGS,
isClaimNsfw, isClaimNsfw,
makeSelectPendingClaimForUri, makeSelectPendingClaimForUri,
makeSelectIsUriResolving, makeSelectIsUriResolving,
@ -105,7 +104,7 @@ export const makeSelectWinningUriForQuery = (query: string) => {
} catch (e) {} } catch (e) {}
return createSelector( return createSelector(
makeSelectClientSetting(SETTINGS.SHOW_MATURE), selectShowMatureContent,
makeSelectPendingClaimForUri(uriFromQuery), makeSelectPendingClaimForUri(uriFromQuery),
makeSelectClaimForUri(uriFromQuery), makeSelectClaimForUri(uriFromQuery),
makeSelectClaimForUri(channelUriFromQuery), makeSelectClaimForUri(channelUriFromQuery),

View file

@ -22,7 +22,9 @@ export const makeSelectClientSetting = (setting) =>
createSelector(selectClientSettings, (settings) => (settings ? settings[setting] : undefined)); createSelector(selectClientSettings, (settings) => (settings ? settings[setting] : undefined));
// refactor me // refactor me
export const selectShowMatureContent = SIMPLE_SITE ? () => () => false : makeSelectClientSetting(SETTINGS.SHOW_MATURE); export const selectShowMatureContent = SIMPLE_SITE
? createSelector(() => false)
: makeSelectClientSetting(SETTINGS.SHOW_MATURE);
// and me // and me
export const selectShowRepostedContent = makeSelectClientSetting(SETTINGS.HIDE_REPOSTS); export const selectShowRepostedContent = makeSelectClientSetting(SETTINGS.HIDE_REPOSTS);