check if 'claims' exists before looping over it

This commit is contained in:
Sean Yesmunt 2020-10-19 23:01:34 -04:00
parent 77b27fea99
commit 15737f9b09
2 changed files with 6 additions and 6 deletions

2
dist/bundle.es.js vendored
View file

@ -2518,7 +2518,7 @@ const makeSelectChannelPermUrlForClaimUri = (uri, includePrefix = false) => rese
}); });
const makeSelectMyChannelPermUrlForName = name => reselect.createSelector(selectMyChannelClaims, claims => { const makeSelectMyChannelPermUrlForName = name => reselect.createSelector(selectMyChannelClaims, claims => {
const matchingClaim = claims.find(claim => claim.name === name); const matchingClaim = claims && claims.find(claim => claim.name === name);
return matchingClaim ? matchingClaim.permanent_url : null; return matchingClaim ? matchingClaim.permanent_url : null;
}); });

View file

@ -258,8 +258,8 @@ export const makeSelectMyPurchasesForPage = (query: ?string, page: number = 1) =
const end = Number(page) * Number(PAGE_SIZE); const end = Number(page) * Number(PAGE_SIZE);
return matchingFileInfos && matchingFileInfos.length return matchingFileInfos && matchingFileInfos.length
? matchingFileInfos ? matchingFileInfos
.slice(start, end) .slice(start, end)
.map(fileInfo => fileInfo.canonical_url || fileInfo.permanent_url) .map(fileInfo => fileInfo.canonical_url || fileInfo.permanent_url)
: []; : [];
} }
); );
@ -365,8 +365,8 @@ export const makeSelectDateForUri = (uri: string) =>
(claim.value.release_time (claim.value.release_time
? claim.value.release_time * 1000 ? claim.value.release_time * 1000
: claim.meta && claim.meta.creation_timestamp : claim.meta && claim.meta.creation_timestamp
? claim.meta.creation_timestamp * 1000 ? claim.meta.creation_timestamp * 1000
: null); : null);
if (!timestamp) { if (!timestamp) {
return undefined; return undefined;
} }
@ -667,7 +667,7 @@ export const makeSelectMyChannelPermUrlForName = (name: string) =>
createSelector( createSelector(
selectMyChannelClaims, selectMyChannelClaims,
claims => { claims => {
const matchingClaim = claims.find(claim => claim.name === name); const matchingClaim = claims && claims.find(claim => claim.name === name);
return matchingClaim ? matchingClaim.permanent_url : null; return matchingClaim ? matchingClaim.permanent_url : null;
} }
); );