add selector for nsfw tags

This commit is contained in:
Sean Yesmunt 2019-04-23 15:02:32 -04:00
parent 5f0fd9e9a5
commit 8629f10765
4 changed files with 35 additions and 2 deletions
dist
src
index.js
redux/selectors
util

17
dist/bundle.es.js vendored
View file

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

View file

@ -117,6 +117,7 @@ export {
makeSelectTotalPagesForChannel,
makeSelectNsfwCountFromUris,
makeSelectNsfwCountForChannel,
makeSelectClaimIsNsfw,
makeSelectRecommendedContentForUri,
makeSelectFirstRecommendedFileForUri,
makeSelectChannelForClaimUri,

View file

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

View file

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