refactor select collection index / next
This commit is contained in:
parent
6d160b3d14
commit
97cd2dbd6a
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;
|
return ids;
|
||||||
});
|
});
|
||||||
|
|
||||||
const makeSelectNextUrlForCollection = (id, index) => reselect.createSelector(makeSelectUrlsForCollectionId(id), urls => {
|
const makeSelectIndexForUrlInCollection = (url, id) => reselect.createSelector(makeSelectUrlsForCollectionId(id), urls => {
|
||||||
const url = urls[index + 1];
|
const index = urls.findIndex(u => u === url);
|
||||||
if (url) {
|
if (index > -1) {
|
||||||
return url;
|
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;
|
return null;
|
||||||
});
|
});
|
||||||
|
@ -7916,6 +7926,7 @@ exports.makeSelectFileInfoForUri = makeSelectFileInfoForUri;
|
||||||
exports.makeSelectFileNameForUri = makeSelectFileNameForUri;
|
exports.makeSelectFileNameForUri = makeSelectFileNameForUri;
|
||||||
exports.makeSelectFilePartlyDownloaded = makeSelectFilePartlyDownloaded;
|
exports.makeSelectFilePartlyDownloaded = makeSelectFilePartlyDownloaded;
|
||||||
exports.makeSelectFilteredTransactionsForPage = makeSelectFilteredTransactionsForPage;
|
exports.makeSelectFilteredTransactionsForPage = makeSelectFilteredTransactionsForPage;
|
||||||
|
exports.makeSelectIndexForUrlInCollection = makeSelectIndexForUrlInCollection;
|
||||||
exports.makeSelectIsAbandoningClaimForUri = makeSelectIsAbandoningClaimForUri;
|
exports.makeSelectIsAbandoningClaimForUri = makeSelectIsAbandoningClaimForUri;
|
||||||
exports.makeSelectIsResolvingCollectionForId = makeSelectIsResolvingCollectionForId;
|
exports.makeSelectIsResolvingCollectionForId = makeSelectIsResolvingCollectionForId;
|
||||||
exports.makeSelectIsUriResolving = makeSelectIsUriResolving;
|
exports.makeSelectIsUriResolving = makeSelectIsUriResolving;
|
||||||
|
@ -7929,7 +7940,7 @@ exports.makeSelectMyPublishedCollectionForId = makeSelectMyPublishedCollectionFo
|
||||||
exports.makeSelectMyPurchasesForPage = makeSelectMyPurchasesForPage;
|
exports.makeSelectMyPurchasesForPage = makeSelectMyPurchasesForPage;
|
||||||
exports.makeSelectMyStreamUrlsForPage = makeSelectMyStreamUrlsForPage;
|
exports.makeSelectMyStreamUrlsForPage = makeSelectMyStreamUrlsForPage;
|
||||||
exports.makeSelectNameForCollectionId = makeSelectNameForCollectionId;
|
exports.makeSelectNameForCollectionId = makeSelectNameForCollectionId;
|
||||||
exports.makeSelectNextUrlForCollection = makeSelectNextUrlForCollection;
|
exports.makeSelectNextUrlForCollectionAndUrl = makeSelectNextUrlForCollectionAndUrl;
|
||||||
exports.makeSelectNsfwCountForChannel = makeSelectNsfwCountForChannel;
|
exports.makeSelectNsfwCountForChannel = makeSelectNsfwCountForChannel;
|
||||||
exports.makeSelectNsfwCountFromUris = makeSelectNsfwCountFromUris;
|
exports.makeSelectNsfwCountFromUris = makeSelectNsfwCountFromUris;
|
||||||
exports.makeSelectOmittedCountForChannel = makeSelectOmittedCountForChannel;
|
exports.makeSelectOmittedCountForChannel = makeSelectOmittedCountForChannel;
|
||||||
|
|
|
@ -179,7 +179,8 @@ export {
|
||||||
makeSelectNameForCollectionId,
|
makeSelectNameForCollectionId,
|
||||||
makeSelectCountForCollectionId,
|
makeSelectCountForCollectionId,
|
||||||
makeSelectIsResolvingCollectionForId,
|
makeSelectIsResolvingCollectionForId,
|
||||||
makeSelectNextUrlForCollection,
|
makeSelectIndexForUrlInCollection,
|
||||||
|
makeSelectNextUrlForCollectionAndUrl,
|
||||||
makeSelectCollectionForIdHasClaimUrl,
|
makeSelectCollectionForIdHasClaimUrl,
|
||||||
} from 'redux/selectors/collections';
|
} 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(
|
createSelector(
|
||||||
makeSelectUrlsForCollectionId(id),
|
makeSelectUrlsForCollectionId(id),
|
||||||
urls => {
|
urls => {
|
||||||
const url = urls[index + 1];
|
const index = urls.findIndex(u => u === url);
|
||||||
if (url) {
|
if (index > -1) {
|
||||||
return url;
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue