diff --git a/dist/bundle.es.js b/dist/bundle.es.js index 99e4db3..6ed46ed 100644 --- a/dist/bundle.es.js +++ b/dist/bundle.es.js @@ -2644,6 +2644,11 @@ const makeSelectTotalPagesInChannelSearch = uri => reselect.createSelector(selec return byChannel['pageCount']; }); +const selectMetadataForUri = reReselect.createCachedSelector(selectClaimForUri, (claim, uri) => { + const metadata = claim && claim.value; + return metadata || (claim === undefined ? undefined : null); +})((state, uri) => uri); + const makeSelectMetadataForUri = uri => reselect.createSelector(makeSelectClaimForUri(uri), claim => { const metadata = claim && claim.value; return metadata || (claim === undefined ? undefined : null); @@ -2860,6 +2865,10 @@ const makeSelectMyChannelPermUrlForName = name => reselect.createSelector(select return matchingClaim ? matchingClaim.permanent_url : null; }); +const selectTagsForUri = reReselect.createCachedSelector(selectMetadataForUri, metadata => { + return metadata && metadata.tags || []; +})((state, uri) => uri); + const makeSelectTagsForUri = uri => reselect.createSelector(makeSelectMetadataForUri(uri), metadata => { return metadata && metadata.tags || []; }); @@ -8248,6 +8257,7 @@ exports.selectIsResolvingPublishUris = selectIsResolvingPublishUris; exports.selectIsSendingSupport = selectIsSendingSupport; exports.selectIsStillEditing = selectIsStillEditing; exports.selectIsWalletReconnecting = selectIsWalletReconnecting; +exports.selectMetadataForUri = selectMetadataForUri; exports.selectMyActiveClaims = selectMyActiveClaims; exports.selectMyChannelClaims = selectMyChannelClaims; exports.selectMyChannelUrls = selectMyChannelUrls; @@ -8289,6 +8299,7 @@ exports.selectResolvingUris = selectResolvingUris; exports.selectSavedCollectionIds = selectSavedCollectionIds; exports.selectSupportsBalance = selectSupportsBalance; exports.selectSupportsByOutpoint = selectSupportsByOutpoint; +exports.selectTagsForUri = selectTagsForUri; exports.selectTakeOverAmount = selectTakeOverAmount; exports.selectTipsBalance = selectTipsBalance; exports.selectToast = selectToast; diff --git a/src/index.js b/src/index.js index 15b24f4..d812678 100644 --- a/src/index.js +++ b/src/index.js @@ -196,6 +196,7 @@ export { makeSelectClaimsInChannelForPage, makeSelectTotalPagesInChannelSearch, makeSelectTotalClaimsInChannelSearch, + selectMetadataForUri, makeSelectMetadataForUri, makeSelectMetadataItemForUri, makeSelectThumbnailForUri, @@ -205,6 +206,7 @@ export { makeSelectDateForUri, makeSelectAmountForUri, makeSelectEffectiveAmountForUri, + selectTagsForUri, makeSelectTagsForUri, makeSelectTagInClaimOrChannelForUri, makeSelectTotalStakedAmountForChannelUri, diff --git a/src/redux/selectors/claims.js b/src/redux/selectors/claims.js index 56819ed..f439663 100644 --- a/src/redux/selectors/claims.js +++ b/src/redux/selectors/claims.js @@ -340,8 +340,8 @@ export const makeSelectMyPurchasesForPage = (query: ?string, page: number = 1) = const end = Number(page) * Number(CLAIM.PAGE_SIZE); return matchingFileInfos && matchingFileInfos.length ? matchingFileInfos - .slice(start, end) - .map(fileInfo => fileInfo.canonical_url || fileInfo.permanent_url) + .slice(start, end) + .map(fileInfo => fileInfo.canonical_url || fileInfo.permanent_url) : []; } ); @@ -401,6 +401,11 @@ export const makeSelectTotalPagesInChannelSearch = (uri: string) => } ); +export const selectMetadataForUri = createCachedSelector(selectClaimForUri, (claim, uri) => { + const metadata = claim && claim.value; + return metadata || (claim === undefined ? undefined : null); +})((state, uri) => uri); + export const makeSelectMetadataForUri = (uri: string) => createSelector( makeSelectClaimForUri(uri), @@ -435,8 +440,8 @@ export const selectDateForUri = createCachedSelector( (claim.value.release_time ? claim.value.release_time * 1000 : claim.meta && claim.meta.creation_timestamp - ? claim.meta.creation_timestamp * 1000 - : null); + ? claim.meta.creation_timestamp * 1000 + : null); if (!timestamp) { return undefined; } @@ -455,8 +460,8 @@ export const makeSelectDateForUri = (uri: string) => (claim.value.release_time ? claim.value.release_time * 1000 : claim.meta && claim.meta.creation_timestamp - ? claim.meta.creation_timestamp * 1000 - : null); + ? claim.meta.creation_timestamp * 1000 + : null); if (!timestamp) { return undefined; } @@ -785,6 +790,13 @@ export const makeSelectMyChannelPermUrlForName = (name: string) => } ); +export const selectTagsForUri = createCachedSelector( + selectMetadataForUri, + (metadata: ?GenericMetadata) => { + return (metadata && metadata.tags) || []; + } +)((state, uri) => uri); + export const makeSelectTagsForUri = (uri: string) => createSelector( makeSelectMetadataForUri(uri),