From acb7a3b0d86eb100f06ce958d364eb7658f3f475 Mon Sep 17 00:00:00 2001 From: zeppi Date: Wed, 23 Jun 2021 10:43:17 -0400 Subject: [PATCH] selectClaimIdIsPending --- dist/bundle.es.js | 7 ++++++- src/index.js | 1 + src/redux/selectors/claims.js | 17 ++++++++++++----- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/dist/bundle.es.js b/dist/bundle.es.js index 3a2fc4d..cfade36 100644 --- a/dist/bundle.es.js +++ b/dist/bundle.es.js @@ -2418,6 +2418,10 @@ const makeSelectClaimIsPending = uri => reselect.createSelector(selectClaimIdsBy return false; }); +const makeSelectClaimIdIsPending = claimId => reselect.createSelector(selectPendingIds, pendingIds => { + return pendingIds.some(i => i === claimId); +}); + const makeSelectClaimIdForUri = uri => reselect.createSelector(selectClaimIdsByUri, claimIds => claimIds[uri]); const selectReflectingById = reselect.createSelector(selectState$1, state => state.reflectingById); @@ -2632,7 +2636,7 @@ const selectMyClaims = reselect.createSelector(selectMyActiveClaims, selectClaim return [...claims]; }); -const selectMyClaimsWithoutChannels = reselect.createSelector(selectMyClaims, myClaims => myClaims.filter(claim => !claim.name.match(/^@/)).sort((a, b) => a.timestamp - b.timestamp)); +const selectMyClaimsWithoutChannels = reselect.createSelector(selectMyClaims, myClaims => myClaims.filter(claim => claim && !claim.name.match(/^@/)).sort((a, b) => a.timestamp - b.timestamp)); const selectMyClaimUrisWithoutChannels = reselect.createSelector(selectMyClaimsWithoutChannels, myClaims => { return myClaims.sort((a, b) => { @@ -7927,6 +7931,7 @@ exports.makeSelectClaimForClaimId = makeSelectClaimForClaimId; exports.makeSelectClaimForUri = makeSelectClaimForUri; exports.makeSelectClaimHasSource = makeSelectClaimHasSource; exports.makeSelectClaimIdForUri = makeSelectClaimIdForUri; +exports.makeSelectClaimIdIsPending = makeSelectClaimIdIsPending; exports.makeSelectClaimIdsForCollectionId = makeSelectClaimIdsForCollectionId; exports.makeSelectClaimIsMine = makeSelectClaimIsMine; exports.makeSelectClaimIsNsfw = makeSelectClaimIsNsfw; diff --git a/src/index.js b/src/index.js index db1ef86..aba6c58 100644 --- a/src/index.js +++ b/src/index.js @@ -282,6 +282,7 @@ export { selectUpdateCollectionError, selectCreatingCollection, selectCreateCollectionError, + makeSelectClaimIdIsPending, } from 'redux/selectors/claims'; export { diff --git a/src/redux/selectors/claims.js b/src/redux/selectors/claims.js index cca04fd..683077d 100644 --- a/src/redux/selectors/claims.js +++ b/src/redux/selectors/claims.js @@ -95,6 +95,13 @@ export const makeSelectClaimIsPending = (uri: string) => } ); +export const makeSelectClaimIdIsPending = (claimId: string) => createSelector( + selectPendingIds, + (pendingIds) => { + return pendingIds.some(i => i === claimId); + } +); + export const makeSelectClaimIdForUri = (uri: string) => createSelector( selectClaimIdsByUri, @@ -279,8 +286,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) : []; } ); @@ -386,8 +393,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; } @@ -493,7 +500,7 @@ export const selectMyClaims = createSelector( export const selectMyClaimsWithoutChannels = createSelector( selectMyClaims, myClaims => - myClaims.filter(claim => !claim.name.match(/^@/)).sort((a, b) => a.timestamp - b.timestamp) + myClaims.filter(claim => claim && !claim.name.match(/^@/)).sort((a, b) => a.timestamp - b.timestamp) ); export const selectMyClaimUrisWithoutChannels = createSelector( -- 2.45.2