diff --git a/dist/bundle.es.js b/dist/bundle.es.js index eb1280e..87be288 100644 --- a/dist/bundle.es.js +++ b/dist/bundle.es.js @@ -1128,7 +1128,8 @@ const isClaimNsfw = claim => { const tags = claim.value.tags || []; for (let i = 0; i < tags.length; i += 1) { - if (naughtyTags[tags[i]]) { + const tag = tags[i].toLowerCase(); + if (naughtyTags[tag]) { return true; } } @@ -1319,6 +1320,19 @@ const makeSelectNsfwCountForChannel = uri => reselect.createSelector(selectClaim }, 0); }); +const makeSelectClaimIsNsfw = uri => reselect.createSelector(makeSelectClaimForUri(uri), +// Eventually these will come from some list of tags that are considered adult +// Or possibly come from users settings of what tags they want to hide +// For now, there is just a hard coded list of tags inside `isClaimNsfw` +// selectNaughtyTags(), +claim => { + if (!claim) { + return false; + } + + return isClaimNsfw(claim); +}); + const makeSelectRecommendedContentForUri = uri => reselect.createSelector(makeSelectClaimForUri(uri), selectSearchUrisByQuery, (claim, searchUrisByQuery) => { const atVanityURI = !uri.includes('#'); @@ -3462,6 +3476,7 @@ exports.makeSelectBlockDate = makeSelectBlockDate; exports.makeSelectChannelForClaimUri = makeSelectChannelForClaimUri; exports.makeSelectClaimForUri = makeSelectClaimForUri; exports.makeSelectClaimIsMine = makeSelectClaimIsMine; +exports.makeSelectClaimIsNsfw = makeSelectClaimIsNsfw; exports.makeSelectClaimIsPending = makeSelectClaimIsPending; exports.makeSelectClaimsInChannelForCurrentPageState = makeSelectClaimsInChannelForCurrentPageState; exports.makeSelectClaimsInChannelForPage = makeSelectClaimsInChannelForPage; diff --git a/src/index.js b/src/index.js index 930e010..46467c4 100644 --- a/src/index.js +++ b/src/index.js @@ -117,6 +117,7 @@ export { makeSelectTotalPagesForChannel, makeSelectNsfwCountFromUris, makeSelectNsfwCountForChannel, + makeSelectClaimIsNsfw, makeSelectRecommendedContentForUri, makeSelectFirstRecommendedFileForUri, makeSelectChannelForClaimUri, diff --git a/src/redux/selectors/claims.js b/src/redux/selectors/claims.js index 65b05b5..477dfac 100644 --- a/src/redux/selectors/claims.js +++ b/src/redux/selectors/claims.js @@ -331,6 +331,22 @@ export const makeSelectNsfwCountForChannel = (uri: string) => } ); +export const makeSelectClaimIsNsfw = (uri: string): boolean => + createSelector( + makeSelectClaimForUri(uri), + // Eventually these will come from some list of tags that are considered adult + // Or possibly come from users settings of what tags they want to hide + // For now, there is just a hard coded list of tags inside `isClaimNsfw` + // selectNaughtyTags(), + (claim: StreamClaim) => { + if (!claim) { + return false; + } + + return isClaimNsfw(claim); + } + ); + export const makeSelectRecommendedContentForUri = (uri: string) => createSelector( makeSelectClaimForUri(uri), diff --git a/src/util/claim.js b/src/util/claim.js index e97ef8f..0e56ce3 100644 --- a/src/util/claim.js +++ b/src/util/claim.js @@ -16,7 +16,8 @@ export const isClaimNsfw = (claim: StreamClaim): boolean => { const tags = claim.value.tags || []; for (let i = 0; i < tags.length; i += 1) { - if (naughtyTags[tags[i]]) { + const tag = tags[i].toLowerCase(); + if (naughtyTags[tag]) { return true; } }