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'];
});
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;

View file

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

View file

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