refactor select collection index / next
This commit is contained in:
parent
32a85a9ff3
commit
503e18be1b
3 changed files with 37 additions and 10 deletions
21
dist/bundle.es.js
vendored
21
dist/bundle.es.js
vendored
|
@ -3694,10 +3694,20 @@ const makeSelectClaimIdsForCollectionId = id => reselect.createSelector(makeSele
|
|||
return ids;
|
||||
});
|
||||
|
||||
const makeSelectNextUrlForCollection = (id, index) => reselect.createSelector(makeSelectUrlsForCollectionId(id), urls => {
|
||||
const url = urls[index + 1];
|
||||
if (url) {
|
||||
return url;
|
||||
const makeSelectIndexForUrlInCollection = (url, id) => reselect.createSelector(makeSelectUrlsForCollectionId(id), urls => {
|
||||
const index = urls.findIndex(u => u === url);
|
||||
if (index > -1) {
|
||||
return index;
|
||||
}
|
||||
return null;
|
||||
});
|
||||
|
||||
const makeSelectNextUrlForCollectionAndUrl = (id, url) => reselect.createSelector(makeSelectIndexForUrlInCollection(url, id), makeSelectUrlsForCollectionId(id), (index, urls) => {
|
||||
if (urls && index >= -1) {
|
||||
const url = urls[index + 1];
|
||||
if (url) {
|
||||
return url;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
});
|
||||
|
@ -7927,6 +7937,7 @@ exports.makeSelectFileInfoForUri = makeSelectFileInfoForUri;
|
|||
exports.makeSelectFileNameForUri = makeSelectFileNameForUri;
|
||||
exports.makeSelectFilePartlyDownloaded = makeSelectFilePartlyDownloaded;
|
||||
exports.makeSelectFilteredTransactionsForPage = makeSelectFilteredTransactionsForPage;
|
||||
exports.makeSelectIndexForUrlInCollection = makeSelectIndexForUrlInCollection;
|
||||
exports.makeSelectIsAbandoningClaimForUri = makeSelectIsAbandoningClaimForUri;
|
||||
exports.makeSelectIsResolvingCollectionForId = makeSelectIsResolvingCollectionForId;
|
||||
exports.makeSelectIsUriResolving = makeSelectIsUriResolving;
|
||||
|
@ -7940,7 +7951,7 @@ exports.makeSelectMyPublishedCollectionForId = makeSelectMyPublishedCollectionFo
|
|||
exports.makeSelectMyPurchasesForPage = makeSelectMyPurchasesForPage;
|
||||
exports.makeSelectMyStreamUrlsForPage = makeSelectMyStreamUrlsForPage;
|
||||
exports.makeSelectNameForCollectionId = makeSelectNameForCollectionId;
|
||||
exports.makeSelectNextUrlForCollection = makeSelectNextUrlForCollection;
|
||||
exports.makeSelectNextUrlForCollectionAndUrl = makeSelectNextUrlForCollectionAndUrl;
|
||||
exports.makeSelectNsfwCountForChannel = makeSelectNsfwCountForChannel;
|
||||
exports.makeSelectNsfwCountFromUris = makeSelectNsfwCountFromUris;
|
||||
exports.makeSelectOmittedCountForChannel = makeSelectOmittedCountForChannel;
|
||||
|
|
|
@ -179,7 +179,8 @@ export {
|
|||
makeSelectNameForCollectionId,
|
||||
makeSelectCountForCollectionId,
|
||||
makeSelectIsResolvingCollectionForId,
|
||||
makeSelectNextUrlForCollection,
|
||||
makeSelectIndexForUrlInCollection,
|
||||
makeSelectNextUrlForCollectionAndUrl,
|
||||
makeSelectCollectionForIdHasClaimUrl,
|
||||
} from 'redux/selectors/collections';
|
||||
|
||||
|
|
|
@ -184,13 +184,28 @@ export const makeSelectClaimIdsForCollectionId = (id: string) =>
|
|||
}
|
||||
);
|
||||
|
||||
export const makeSelectNextUrlForCollection = (id: string, index: number) =>
|
||||
export const makeSelectIndexForUrlInCollection = (url: string, id: string) =>
|
||||
createSelector(
|
||||
makeSelectUrlsForCollectionId(id),
|
||||
urls => {
|
||||
const url = urls[index + 1];
|
||||
if (url) {
|
||||
return url;
|
||||
const index = urls.findIndex(u => u === url);
|
||||
if (index > -1) {
|
||||
return index;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
);
|
||||
|
||||
export const makeSelectNextUrlForCollectionAndUrl = (id: string, url: string) =>
|
||||
createSelector(
|
||||
makeSelectIndexForUrlInCollection(url, id),
|
||||
makeSelectUrlsForCollectionId(id),
|
||||
(index, urls) => {
|
||||
if (urls && index >= -1) {
|
||||
const url = urls[index + 1];
|
||||
if (url) {
|
||||
return url;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue