From b4e91cfdec84cc5c3bbda377e9467983c82dcb01 Mon Sep 17 00:00:00 2001 From: zeppi Date: Wed, 31 Mar 2021 16:29:48 -0400 Subject: [PATCH] use show mature selector --- ui/component/channelContent/index.js | 4 ++-- ui/component/claimListDiscover/index.js | 4 ++-- ui/component/claimListHeader/index.js | 6 +++--- ui/component/claimTilesDiscover/index.js | 4 ++-- ui/component/wunderbarSuggestions/index.js | 12 ++++++------ ui/page/home/index.js | 7 +++---- ui/page/search/index.js | 14 +++++++------- ui/page/settings/index.js | 9 +++++++-- ui/redux/selectors/comments.js | 9 ++++----- ui/redux/selectors/search.js | 5 ++--- ui/redux/selectors/settings.js | 4 +++- 11 files changed, 41 insertions(+), 37 deletions(-) diff --git a/ui/component/channelContent/index.js b/ui/component/channelContent/index.js index 183d3ac88..5338a7218 100644 --- a/ui/component/channelContent/index.js +++ b/ui/component/channelContent/index.js @@ -12,7 +12,7 @@ import { import { makeSelectChannelIsMuted } from 'redux/selectors/blocked'; import { withRouter } from 'react-router'; import { selectUserVerifiedEmail } from 'redux/selectors/user'; -import { makeSelectClientSetting } from 'redux/selectors/settings'; +import { makeSelectClientSetting, selectShowMatureContent } from 'redux/selectors/settings'; import ChannelPage from './view'; @@ -28,7 +28,7 @@ const select = (state, props) => { channelIsBlocked: makeSelectChannelIsMuted(props.uri)(state), claim: props.uri && makeSelectClaimForUri(props.uri)(state), isAuthenticated: selectUserVerifiedEmail(state), - showMature: makeSelectClientSetting(SETTINGS.SHOW_MATURE)(state), + showMature: selectShowMatureContent(state), tileLayout: makeSelectClientSetting(SETTINGS.TILE_LAYOUT)(state), }; }; diff --git a/ui/component/claimListDiscover/index.js b/ui/component/claimListDiscover/index.js index e31b36103..db5d76259 100644 --- a/ui/component/claimListDiscover/index.js +++ b/ui/component/claimListDiscover/index.js @@ -9,7 +9,7 @@ import { import { selectFollowedTags } from 'redux/selectors/tags'; import { selectMutedChannels } from 'redux/selectors/blocked'; 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 ClaimListDiscover from './view'; @@ -18,7 +18,7 @@ const select = (state) => ({ claimSearchByQuery: selectClaimSearchByQuery(state), claimSearchByQueryLastPageReached: selectClaimSearchByQueryLastPageReached(state), loading: selectFetchingClaimSearch(state), - showNsfw: makeSelectClientSetting(SETTINGS.SHOW_MATURE)(state), + showNsfw: selectShowMatureContent(state), hideReposts: makeSelectClientSetting(SETTINGS.HIDE_REPOSTS)(state), languageSetting: selectLanguage(state), mutedUris: selectMutedChannels(state), diff --git a/ui/component/claimListHeader/index.js b/ui/component/claimListHeader/index.js index b8e221a0d..994329044 100644 --- a/ui/component/claimListHeader/index.js +++ b/ui/component/claimListHeader/index.js @@ -2,14 +2,14 @@ import { connect } from 'react-redux'; import { selectFetchingClaimSearch, SETTINGS } from 'lbry-redux'; import { selectFollowedTags } from 'redux/selectors/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 ClaimListHeader from './view'; -const select = state => ({ +const select = (state) => ({ followedTags: selectFollowedTags(state), loading: selectFetchingClaimSearch(state), - showNsfw: makeSelectClientSetting(SETTINGS.SHOW_MATURE)(state), + showNsfw: selectShowMatureContent(state), searchInLanguage: makeSelectClientSetting(SETTINGS.SEARCH_IN_LANGUAGE)(state), languageSetting: selectLanguage(state), }); diff --git a/ui/component/claimTilesDiscover/index.js b/ui/component/claimTilesDiscover/index.js index b509abae7..f52a687cc 100644 --- a/ui/component/claimTilesDiscover/index.js +++ b/ui/component/claimTilesDiscover/index.js @@ -1,13 +1,13 @@ import { connect } from 'react-redux'; import { doClaimSearch, selectClaimSearchByQuery, selectFetchingClaimSearchByQuery, SETTINGS } from 'lbry-redux'; import { doToggleTagFollowDesktop } from 'redux/actions/tags'; -import { makeSelectClientSetting } from 'redux/selectors/settings'; +import { makeSelectClientSetting, selectShowMatureContent } from 'redux/selectors/settings'; import ClaimListDiscover from './view'; const select = (state) => ({ claimSearchByQuery: selectClaimSearchByQuery(state), fetchingClaimSearchByQuery: selectFetchingClaimSearchByQuery(state), - showNsfw: makeSelectClientSetting(SETTINGS.SHOW_MATURE)(state), + showNsfw: selectShowMatureContent(state), hideReposts: makeSelectClientSetting(SETTINGS.HIDE_REPOSTS)(state), }); diff --git a/ui/component/wunderbarSuggestions/index.js b/ui/component/wunderbarSuggestions/index.js index 873ffc9aa..5a43cc271 100644 --- a/ui/component/wunderbarSuggestions/index.js +++ b/ui/component/wunderbarSuggestions/index.js @@ -1,28 +1,28 @@ import * as MODALS from 'constants/modal_types'; 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 { doSearch } from 'redux/actions/search'; import { doOpenModal, doHideModal } from 'redux/actions/app'; import { withRouter } from 'react-router'; -import { doResolveUris, SETTINGS } from 'lbry-redux'; +import { doResolveUris } from 'lbry-redux'; import analytics from 'analytics'; import Wunderbar from './view'; const select = (state, props) => ({ language: selectLanguage(state), - showMature: makeSelectClientSetting(SETTINGS.SHOW_MATURE)(state), + showMature: selectShowMatureContent(state), }); const perform = (dispatch, ownProps) => ({ - doResolveUris: uris => dispatch(doResolveUris(uris)), + doResolveUris: (uris) => dispatch(doResolveUris(uris)), doSearch: (query, options) => dispatch(doSearch(query, options)), - navigateToSearchPage: query => { + navigateToSearchPage: (query) => { let encodedQuery = encodeURIComponent(query); ownProps.history.push({ pathname: `/$/search`, search: `?q=${encodedQuery}` }); analytics.apiLogSearch(); }, - doShowSnackBar: message => dispatch(doToast({ isError: true, message })), + doShowSnackBar: (message) => dispatch(doToast({ isError: true, message })), doOpenMobileSearch: () => dispatch(doOpenModal(MODALS.MOBILE_SEARCH)), doCloseMobileSearch: () => dispatch(doHideModal()), }); diff --git a/ui/page/home/index.js b/ui/page/home/index.js index d6a794b73..40856d304 100644 --- a/ui/page/home/index.js +++ b/ui/page/home/index.js @@ -1,17 +1,16 @@ -import * as SETTINGS from 'constants/settings'; import { connect } from 'react-redux'; import { selectFollowedTags } from 'redux/selectors/tags'; import { selectUserVerifiedEmail } from 'redux/selectors/user'; import { selectSubscriptions } from 'redux/selectors/subscriptions'; -import { makeSelectClientSetting, selectHomepageData } from 'redux/selectors/settings'; +import { selectShowMatureContent, selectHomepageData } from 'redux/selectors/settings'; import DiscoverPage from './view'; -const select = state => ({ +const select = (state) => ({ followedTags: selectFollowedTags(state), subscribedChannels: selectSubscriptions(state), authenticated: selectUserVerifiedEmail(state), - showNsfw: makeSelectClientSetting(SETTINGS.SHOW_MATURE)(state), + showNsfw: selectShowMatureContent(state), homepageData: selectHomepageData(state), }); diff --git a/ui/page/search/index.js b/ui/page/search/index.js index d808e7a7f..2f82e84a9 100644 --- a/ui/page/search/index.js +++ b/ui/page/search/index.js @@ -1,5 +1,5 @@ import { connect } from 'react-redux'; -import { doToast, SETTINGS } from 'lbry-redux'; +import { doToast } from 'lbry-redux'; import { withRouter } from 'react-router'; import { doSearch } from 'redux/actions/search'; import { @@ -8,13 +8,13 @@ import { makeSelectQueryWithOptions, selectSearchOptions, } from 'redux/selectors/search'; -import { makeSelectClientSetting } from 'redux/selectors/settings'; +import { selectShowMatureContent } from 'redux/selectors/settings'; import { selectUserVerifiedEmail } from 'redux/selectors/user'; import analytics from 'analytics'; import SearchPage from './view'; const select = (state, props) => { - const showMature = makeSelectClientSetting(SETTINGS.SHOW_MATURE)(state); + const showMature = selectShowMatureContent(state); const urlParams = new URLSearchParams(props.location.search); let urlQuery = urlParams.get('q') || null; if (urlQuery) { @@ -29,16 +29,16 @@ const select = (state, props) => { return { isSearching: selectIsSearching(state), - showNsfw: makeSelectClientSetting(SETTINGS.SHOW_MATURE)(state), + showNsfw: showMature, uris: uris, isAuthenticated: selectUserVerifiedEmail(state), searchOptions: selectSearchOptions(state), }; }; -const perform = dispatch => ({ +const perform = (dispatch) => ({ search: (query, options) => dispatch(doSearch(query, options)), - onFeedbackPositive: query => { + onFeedbackPositive: (query) => { analytics.apiSearchFeedback(query, 1); dispatch( doToast({ @@ -46,7 +46,7 @@ const perform = dispatch => ({ }) ); }, - onFeedbackNegative: query => { + onFeedbackNegative: (query) => { analytics.apiSearchFeedback(query, 0); dispatch( doToast({ diff --git a/ui/page/settings/index.js b/ui/page/settings/index.js index 5a91416c2..38668b95a 100644 --- a/ui/page/settings/index.js +++ b/ui/page/settings/index.js @@ -10,7 +10,12 @@ import { doExitSettingsPage, } from 'redux/actions/settings'; 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 SettingsPage from './view'; import { selectUserVerifiedEmail } from 'redux/selectors/user'; @@ -19,7 +24,7 @@ const select = (state) => ({ daemonSettings: selectDaemonSettings(state), allowAnalytics: selectAllowAnalytics(state), isAuthenticated: selectUserVerifiedEmail(state), - showNsfw: makeSelectClientSetting(SETTINGS.SHOW_MATURE)(state), + showNsfw: selectShowMatureContent(state), currentTheme: makeSelectClientSetting(SETTINGS.THEME)(state), themes: makeSelectClientSetting(SETTINGS.THEMES)(state), automaticDarkModeEnabled: makeSelectClientSetting(SETTINGS.AUTOMATIC_DARK_MODE_ENABLED)(state), diff --git a/ui/redux/selectors/comments.js b/ui/redux/selectors/comments.js index c7d6f25d3..0e8fcab21 100644 --- a/ui/redux/selectors/comments.js +++ b/ui/redux/selectors/comments.js @@ -1,8 +1,7 @@ // @flow -import * as SETTINGS from 'constants/settings'; import { createSelector } from 'reselect'; import { selectMutedChannels } from 'redux/selectors/blocked'; -import { makeSelectClientSetting } from 'redux/selectors/settings'; +import { selectShowMatureContent } from 'redux/selectors/settings'; import { selectBlacklistedOutpointMap, selectFilteredOutpointMap } from 'lbryinc'; import { selectClaimsById, isClaimNsfw, selectMyActiveClaims } from 'lbry-redux'; @@ -132,7 +131,7 @@ export const makeSelectCommentsForUri = (uri: string) => selectMutedChannels, selectBlacklistedOutpointMap, selectFilteredOutpointMap, - makeSelectClientSetting(SETTINGS.SHOW_MATURE), + selectShowMatureContent, (byClaimId, byUri, claimsById, myClaims, blockedChannels, blacklistedMap, filteredMap, showMatureContent) => { const claimId = byUri[uri]; const comments = byClaimId && byClaimId[claimId]; @@ -183,7 +182,7 @@ export const makeSelectTopLevelCommentsForUri = (uri: string) => selectMutedChannels, selectBlacklistedOutpointMap, selectFilteredOutpointMap, - makeSelectClientSetting(SETTINGS.SHOW_MATURE), + selectShowMatureContent, (byClaimId, byUri, claimsById, myClaims, blockedChannels, blacklistedMap, filteredMap, showMatureContent) => { const claimId = byUri[uri]; const comments = byClaimId && byClaimId[claimId]; @@ -233,7 +232,7 @@ export const makeSelectRepliesForParentId = (id: string) => selectMutedChannels, selectBlacklistedOutpointMap, selectFilteredOutpointMap, - makeSelectClientSetting(SETTINGS.SHOW_MATURE), + selectShowMatureContent, (state, commentsById, claimsById, myClaims, blockedChannels, blacklistedMap, filteredMap, showMatureContent) => { // const claimId = byUri[uri]; // just parentId (id) const replyIdsByParentId = state.repliesByParentId; diff --git a/ui/redux/selectors/search.js b/ui/redux/selectors/search.js index 7c9dcbf46..dcde45600 100644 --- a/ui/redux/selectors/search.js +++ b/ui/redux/selectors/search.js @@ -1,12 +1,11 @@ // @flow import { getSearchQueryString } from 'util/query-params'; -import { makeSelectClientSetting } from 'redux/selectors/settings'; +import { selectShowMatureContent } from 'redux/selectors/settings'; import { parseURI, makeSelectClaimForUri, makeSelectClaimIsNsfw, buildURI, - SETTINGS, isClaimNsfw, makeSelectPendingClaimForUri, makeSelectIsUriResolving, @@ -105,7 +104,7 @@ export const makeSelectWinningUriForQuery = (query: string) => { } catch (e) {} return createSelector( - makeSelectClientSetting(SETTINGS.SHOW_MATURE), + selectShowMatureContent, makeSelectPendingClaimForUri(uriFromQuery), makeSelectClaimForUri(uriFromQuery), makeSelectClaimForUri(channelUriFromQuery), diff --git a/ui/redux/selectors/settings.js b/ui/redux/selectors/settings.js index 6b48bab97..85b700b8e 100644 --- a/ui/redux/selectors/settings.js +++ b/ui/redux/selectors/settings.js @@ -22,7 +22,9 @@ export const makeSelectClientSetting = (setting) => createSelector(selectClientSettings, (settings) => (settings ? settings[setting] : undefined)); // 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 export const selectShowRepostedContent = makeSelectClientSetting(SETTINGS.HIDE_REPOSTS);