add generic metadata selector

This commit is contained in:
Sean Yesmunt 2019-05-06 13:57:07 -04:00
parent 26d68d8259
commit 459bea2257
3 changed files with 16 additions and 2 deletions

5
dist/bundle.es.js vendored
View file

@ -1231,6 +1231,10 @@ const makeSelectMetadataForUri = uri => reselect.createSelector(makeSelectClaimF
return metadata || (claim === undefined ? undefined : null); return metadata || (claim === undefined ? undefined : null);
}); });
const makeSelectMetadataItemForUri = (uri, key) => reselect.createSelector(makeSelectMetadataForUri(uri), metadata => {
return metadata ? metadata[key] : undefined;
});
const makeSelectTitleForUri = uri => reselect.createSelector(makeSelectMetadataForUri(uri), metadata => metadata && metadata.title); const makeSelectTitleForUri = uri => reselect.createSelector(makeSelectMetadataForUri(uri), metadata => metadata && metadata.title);
const makeSelectContentTypeForUri = uri => reselect.createSelector(makeSelectClaimForUri(uri), claim => { const makeSelectContentTypeForUri = uri => reselect.createSelector(makeSelectClaimForUri(uri), claim => {
@ -3496,6 +3500,7 @@ exports.makeSelectFirstRecommendedFileForUri = makeSelectFirstRecommendedFileFor
exports.makeSelectIsUriResolving = makeSelectIsUriResolving; exports.makeSelectIsUriResolving = makeSelectIsUriResolving;
exports.makeSelectLoadingForUri = makeSelectLoadingForUri; exports.makeSelectLoadingForUri = makeSelectLoadingForUri;
exports.makeSelectMetadataForUri = makeSelectMetadataForUri; exports.makeSelectMetadataForUri = makeSelectMetadataForUri;
exports.makeSelectMetadataItemForUri = makeSelectMetadataItemForUri;
exports.makeSelectNsfwCountForChannel = makeSelectNsfwCountForChannel; exports.makeSelectNsfwCountForChannel = makeSelectNsfwCountForChannel;
exports.makeSelectNsfwCountFromUris = makeSelectNsfwCountFromUris; exports.makeSelectNsfwCountFromUris = makeSelectNsfwCountFromUris;
exports.makeSelectPendingByUri = makeSelectPendingByUri; exports.makeSelectPendingByUri = makeSelectPendingByUri;

View file

@ -110,6 +110,9 @@ export {
makeSelectFetchingChannelClaims, makeSelectFetchingChannelClaims,
makeSelectClaimsInChannelForPage, makeSelectClaimsInChannelForPage,
makeSelectMetadataForUri, makeSelectMetadataForUri,
makeSelectMetadataItemForUri,
makeSelectThumbnailForUri,
makeSelectCoverForUri,
makeSelectTitleForUri, makeSelectTitleForUri,
makeSelectContentTypeForUri, makeSelectContentTypeForUri,
makeSelectIsUriResolving, makeSelectIsUriResolving,
@ -144,8 +147,6 @@ export {
selectPlayingUri, selectPlayingUri,
selectChannelClaimCounts, selectChannelClaimCounts,
selectCurrentChannelPage, selectCurrentChannelPage,
makeSelectThumbnailForUri,
makeSelectCoverForUri,
} from 'redux/selectors/claims'; } from 'redux/selectors/claims';
export { export {

View file

@ -172,6 +172,14 @@ export const makeSelectMetadataForUri = (uri: string) =>
} }
); );
export const makeSelectMetadataItemForUri = (uri: string, key: string) =>
createSelector(
makeSelectMetadataForUri(uri),
(metadata: ChannelMetadata | StreamMetadata) => {
return metadata ? metadata[key] : undefined;
}
);
export const makeSelectTitleForUri = (uri: string) => export const makeSelectTitleForUri = (uri: string) =>
createSelector( createSelector(
makeSelectMetadataForUri(uri), makeSelectMetadataForUri(uri),