use show mature selector #5803

Merged
jessopb merged 1 commit from fix-use-ShowMature-selector into master 2021-03-31 22:55:26 +02:00
11 changed files with 41 additions and 37 deletions

View file

@ -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),
};
};

View file

@ -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),

View file

@ -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),
});

View file

@ -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),
});

View file

@ -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()),
});

View file

@ -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),
});

View file

@ -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({

View file

@ -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),

View file

@ -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;

View file

@ -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),

View file

@ -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);