Add claim in collections selector

This commit is contained in:
saltrafael 2021-07-05 13:02:06 -03:00 committed by jessopb
parent aabae5ce59
commit bee9bf38dd
3 changed files with 36 additions and 0 deletions

14
dist/bundle.es.js vendored
View file

@ -3697,6 +3697,19 @@ const makeSelectCollectionForId = id => reselect.createSelector(selectBuiltinCol
return collection;
});
const makeSelectClaimUrlInCollection = url => reselect.createSelector(selectBuiltinCollections, selectResolvedCollections, selectMyUnpublishedCollections, selectMyEditedCollections, selectPendingCollections, (bLists, rLists, uLists, eLists, pLists) => {
const collections = [bLists, uLists, eLists, rLists, pLists];
const itemsInCollections = [];
collections.map(list => {
Object.entries(list).forEach(([key, value]) => {
value.items.map(item => {
itemsInCollections.push(item);
});
});
});
return itemsInCollections.includes(url);
});
const makeSelectCollectionForIdHasClaimUrl = (id, url) => reselect.createSelector(makeSelectCollectionForId(id), collection => collection && collection.items.includes(url));
const makeSelectUrlsForCollectionId = id => reselect.createSelector(makeSelectCollectionForId(id), collection => collection && collection.items);
@ -7981,6 +7994,7 @@ exports.makeSelectClaimIsMine = makeSelectClaimIsMine;
exports.makeSelectClaimIsNsfw = makeSelectClaimIsNsfw;
exports.makeSelectClaimIsPending = makeSelectClaimIsPending;
exports.makeSelectClaimIsStreamPlaceholder = makeSelectClaimIsStreamPlaceholder;
exports.makeSelectClaimUrlInCollection = makeSelectClaimUrlInCollection;
exports.makeSelectClaimWasPurchased = makeSelectClaimWasPurchased;
exports.makeSelectClaimsInChannelForPage = makeSelectClaimsInChannelForPage;
exports.makeSelectCollectionForId = makeSelectCollectionForId;

View file

@ -176,6 +176,7 @@ export {
makeSelectMyPublishedCollectionForId,
makeSelectUnpublishedCollectionForId,
makeSelectCollectionForId,
makeSelectClaimUrlInCollection,
makeSelectUrlsForCollectionId,
makeSelectClaimIdsForCollectionId,
makeSelectNameForCollectionId,

View file

@ -163,6 +163,27 @@ export const makeSelectCollectionForId = (id: string) =>
}
);
export const makeSelectClaimUrlInCollection = (url: string) =>
createSelector(
selectBuiltinCollections,
selectResolvedCollections,
selectMyUnpublishedCollections,
selectMyEditedCollections,
selectPendingCollections,
(bLists, rLists, uLists, eLists, pLists) => {
const collections = [bLists, uLists, eLists, rLists, pLists];
const itemsInCollections = [];
collections.map(list => {
Object.entries(list).forEach(([key, value]) => {
value.items.map(item => {
itemsInCollections.push(item);
});
});
});
return itemsInCollections.includes(url);
}
);
export const makeSelectCollectionForIdHasClaimUrl = (id: string, url: string) =>
createSelector(
makeSelectCollectionForId(id),