selectMetadataForUri -> selectTagsForUri

This commit is contained in:
infiinte-persistence 2021-10-11 10:42:00 +08:00
parent 393705f5b1
commit afa3272cc8
No known key found for this signature in database
GPG key ID: B9C3252EDC3D0AA0
3 changed files with 31 additions and 6 deletions

11
dist/bundle.es.js vendored
View file

@ -2644,6 +2644,11 @@ const makeSelectTotalPagesInChannelSearch = uri => reselect.createSelector(selec
return byChannel['pageCount']; 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 makeSelectMetadataForUri = uri => reselect.createSelector(makeSelectClaimForUri(uri), claim => {
const metadata = claim && claim.value; const metadata = claim && claim.value;
return metadata || (claim === undefined ? undefined : null); return metadata || (claim === undefined ? undefined : null);
@ -2860,6 +2865,10 @@ const makeSelectMyChannelPermUrlForName = name => reselect.createSelector(select
return matchingClaim ? matchingClaim.permanent_url : null; 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 => { const makeSelectTagsForUri = uri => reselect.createSelector(makeSelectMetadataForUri(uri), metadata => {
return metadata && metadata.tags || []; return metadata && metadata.tags || [];
}); });
@ -8248,6 +8257,7 @@ exports.selectIsResolvingPublishUris = selectIsResolvingPublishUris;
exports.selectIsSendingSupport = selectIsSendingSupport; exports.selectIsSendingSupport = selectIsSendingSupport;
exports.selectIsStillEditing = selectIsStillEditing; exports.selectIsStillEditing = selectIsStillEditing;
exports.selectIsWalletReconnecting = selectIsWalletReconnecting; exports.selectIsWalletReconnecting = selectIsWalletReconnecting;
exports.selectMetadataForUri = selectMetadataForUri;
exports.selectMyActiveClaims = selectMyActiveClaims; exports.selectMyActiveClaims = selectMyActiveClaims;
exports.selectMyChannelClaims = selectMyChannelClaims; exports.selectMyChannelClaims = selectMyChannelClaims;
exports.selectMyChannelUrls = selectMyChannelUrls; exports.selectMyChannelUrls = selectMyChannelUrls;
@ -8289,6 +8299,7 @@ exports.selectResolvingUris = selectResolvingUris;
exports.selectSavedCollectionIds = selectSavedCollectionIds; exports.selectSavedCollectionIds = selectSavedCollectionIds;
exports.selectSupportsBalance = selectSupportsBalance; exports.selectSupportsBalance = selectSupportsBalance;
exports.selectSupportsByOutpoint = selectSupportsByOutpoint; exports.selectSupportsByOutpoint = selectSupportsByOutpoint;
exports.selectTagsForUri = selectTagsForUri;
exports.selectTakeOverAmount = selectTakeOverAmount; exports.selectTakeOverAmount = selectTakeOverAmount;
exports.selectTipsBalance = selectTipsBalance; exports.selectTipsBalance = selectTipsBalance;
exports.selectToast = selectToast; exports.selectToast = selectToast;

View file

@ -196,6 +196,7 @@ export {
makeSelectClaimsInChannelForPage, makeSelectClaimsInChannelForPage,
makeSelectTotalPagesInChannelSearch, makeSelectTotalPagesInChannelSearch,
makeSelectTotalClaimsInChannelSearch, makeSelectTotalClaimsInChannelSearch,
selectMetadataForUri,
makeSelectMetadataForUri, makeSelectMetadataForUri,
makeSelectMetadataItemForUri, makeSelectMetadataItemForUri,
makeSelectThumbnailForUri, makeSelectThumbnailForUri,
@ -205,6 +206,7 @@ export {
makeSelectDateForUri, makeSelectDateForUri,
makeSelectAmountForUri, makeSelectAmountForUri,
makeSelectEffectiveAmountForUri, makeSelectEffectiveAmountForUri,
selectTagsForUri,
makeSelectTagsForUri, makeSelectTagsForUri,
makeSelectTagInClaimOrChannelForUri, makeSelectTagInClaimOrChannelForUri,
makeSelectTotalStakedAmountForChannelUri, makeSelectTotalStakedAmountForChannelUri,

View file

@ -340,8 +340,8 @@ export const makeSelectMyPurchasesForPage = (query: ?string, page: number = 1) =
const end = Number(page) * Number(CLAIM.PAGE_SIZE); const end = Number(page) * Number(CLAIM.PAGE_SIZE);
return matchingFileInfos && matchingFileInfos.length return matchingFileInfos && matchingFileInfos.length
? matchingFileInfos ? matchingFileInfos
.slice(start, end) .slice(start, end)
.map(fileInfo => fileInfo.canonical_url || fileInfo.permanent_url) .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) => export const makeSelectMetadataForUri = (uri: string) =>
createSelector( createSelector(
makeSelectClaimForUri(uri), makeSelectClaimForUri(uri),
@ -435,8 +440,8 @@ export const selectDateForUri = createCachedSelector(
(claim.value.release_time (claim.value.release_time
? claim.value.release_time * 1000 ? claim.value.release_time * 1000
: claim.meta && claim.meta.creation_timestamp : claim.meta && claim.meta.creation_timestamp
? claim.meta.creation_timestamp * 1000 ? claim.meta.creation_timestamp * 1000
: null); : null);
if (!timestamp) { if (!timestamp) {
return undefined; return undefined;
} }
@ -455,8 +460,8 @@ export const makeSelectDateForUri = (uri: string) =>
(claim.value.release_time (claim.value.release_time
? claim.value.release_time * 1000 ? claim.value.release_time * 1000
: claim.meta && claim.meta.creation_timestamp : claim.meta && claim.meta.creation_timestamp
? claim.meta.creation_timestamp * 1000 ? claim.meta.creation_timestamp * 1000
: null); : null);
if (!timestamp) { if (!timestamp) {
return undefined; 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) => export const makeSelectTagsForUri = (uri: string) =>
createSelector( createSelector(
makeSelectMetadataForUri(uri), makeSelectMetadataForUri(uri),