From 5ac2065b6188e213c40eecd8149bc7b5b89e6eeb Mon Sep 17 00:00:00 2001 From: Sean Yesmunt Date: Tue, 23 Jun 2020 11:15:17 -0400 Subject: [PATCH] fix selector to properly return null for abandoned claims --- dist/bundle.es.js | 9 ++++++--- src/redux/selectors/claims.js | 11 +++++++---- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/dist/bundle.es.js b/dist/bundle.es.js index 430b1ae..ee5209b 100644 --- a/dist/bundle.es.js +++ b/dist/bundle.es.js @@ -2227,9 +2227,12 @@ const makeSelectClaimForUri = (uri, returnRepost = true) => reselect.createSelec if (validUri && byUri) { const claimId = uri && byUri[normalizeURI(uri)]; const claim = byId[claimId]; - if (claim === undefined || claim === null) { - // Make sure to return the claim as is so apps can check if it's been resolved before (null) or still needs to be resolved (undefined) - return claim; + + // Make sure to return the claim as is so apps can check if it's been resolved before (null) or still needs to be resolved (undefined) + if (claimId === null) { + return null; + } else if (claimId === undefined) { + return undefined; } const repostedClaim = claim.reposted_claim; diff --git a/src/redux/selectors/claims.js b/src/redux/selectors/claims.js index b724567..eadd945 100644 --- a/src/redux/selectors/claims.js +++ b/src/redux/selectors/claims.js @@ -116,9 +116,12 @@ export const makeSelectClaimForUri = (uri: string, returnRepost: boolean = true) if (validUri && byUri) { const claimId = uri && byUri[normalizeURI(uri)]; const claim = byId[claimId]; - if (claim === undefined || claim === null) { - // Make sure to return the claim as is so apps can check if it's been resolved before (null) or still needs to be resolved (undefined) - return claim; + + // Make sure to return the claim as is so apps can check if it's been resolved before (null) or still needs to be resolved (undefined) + if (claimId === null) { + return null; + } else if (claimId === undefined) { + return undefined; } const repostedClaim = claim.reposted_claim; @@ -512,7 +515,7 @@ export const selectMyChannelClaims = createSelector( export const selectMyChannelUrls = createSelector( selectMyChannelClaims, - claims => claims ? claims.map(claim => claim.canonical_url || claim.permanent_url) : undefined + claims => (claims ? claims.map(claim => claim.canonical_url || claim.permanent_url) : undefined) ); export const selectResolvingUris = createSelector(