add makeSelectTagInClaimOrChannelForUri

This commit is contained in:
jessop 2020-10-27 15:42:53 -04:00 committed by Sean Yesmunt
parent 3cb3859baf
commit 1fc5afa0c4
3 changed files with 35 additions and 4 deletions

7
dist/bundle.es.js vendored
View file

@ -2575,6 +2575,12 @@ const makeSelectMyStreamUrlsForPage = (page = 1) => reselect.createSelector(sele
const selectMyStreamUrlsCount = reselect.createSelector(selectMyClaimUrisWithoutChannels, channels => channels.length); const selectMyStreamUrlsCount = reselect.createSelector(selectMyClaimUrisWithoutChannels, channels => channels.length);
const makeSelectTagInClaimOrChannelForUri = (uri, tag) => reselect.createSelector(makeSelectClaimForUri(uri), claim => {
const claimTags = claim && claim.value && claim.value.tags || [];
const channelTags = claim && claim.signing_channel && claim.signing_channel.value && claim.signing_channel.value.tags || [];
return claimTags.includes(tag) || channelTags.includes(tag);
});
function numberWithCommas(x) { function numberWithCommas(x) {
var parts = x.toString().split('.'); var parts = x.toString().split('.');
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ','); parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',');
@ -6319,6 +6325,7 @@ exports.makeSelectSearchDownloadUrlsForPage = makeSelectSearchDownloadUrlsForPag
exports.makeSelectShortUrlForUri = makeSelectShortUrlForUri; exports.makeSelectShortUrlForUri = makeSelectShortUrlForUri;
exports.makeSelectStreamingUrlForUri = makeSelectStreamingUrlForUri; exports.makeSelectStreamingUrlForUri = makeSelectStreamingUrlForUri;
exports.makeSelectSupportsForUri = makeSelectSupportsForUri; exports.makeSelectSupportsForUri = makeSelectSupportsForUri;
exports.makeSelectTagInClaimOrChannelForUri = makeSelectTagInClaimOrChannelForUri;
exports.makeSelectTagsForUri = makeSelectTagsForUri; exports.makeSelectTagsForUri = makeSelectTagsForUri;
exports.makeSelectThumbnailForUri = makeSelectThumbnailForUri; exports.makeSelectThumbnailForUri = makeSelectThumbnailForUri;
exports.makeSelectTitleForUri = makeSelectTitleForUri; exports.makeSelectTitleForUri = makeSelectTitleForUri;

View file

@ -161,6 +161,7 @@ export {
makeSelectDateForUri, makeSelectDateForUri,
makeSelectAmountForUri, makeSelectAmountForUri,
makeSelectTagsForUri, makeSelectTagsForUri,
makeSelectTagInClaimOrChannelForUri,
makeSelectContentTypeForUri, makeSelectContentTypeForUri,
makeSelectIsUriResolving, makeSelectIsUriResolving,
makeSelectTotalItemsForChannel, makeSelectTotalItemsForChannel,

View file

@ -680,6 +680,14 @@ export const makeSelectTagsForUri = (uri: string) =>
} }
); );
export const makeSelectChannelTagsForUri = (uri: string) =>
createSelector(
makeSelectMetadataForUri(uri),
(metadata: ?GenericMetadata) => {
return (metadata && metadata.tags) || [];
}
);
export const selectFetchingClaimSearchByQuery = createSelector( export const selectFetchingClaimSearchByQuery = createSelector(
selectState, selectState,
state => state.fetchingClaimSearchByQuery || {} state => state.fetchingClaimSearchByQuery || {}
@ -775,3 +783,18 @@ export const selectMyStreamUrlsCount = createSelector(
selectMyClaimUrisWithoutChannels, selectMyClaimUrisWithoutChannels,
channels => channels.length channels => channels.length
); );
export const makeSelectTagInClaimOrChannelForUri = (uri: string, tag: string) =>
createSelector(
makeSelectClaimForUri(uri),
claim => {
const claimTags = (claim && claim.value && claim.value.tags) || [];
const channelTags =
(claim &&
claim.signing_channel &&
claim.signing_channel.value &&
claim.signing_channel.value.tags) ||
[];
return claimTags.includes(tag) || channelTags.includes(tag);
}
);