handle cases where no claim object is present
This commit is contained in:
parent
0ce0cf1de3
commit
f6e99498d2
2 changed files with 49 additions and 33 deletions
17
dist/bundle.es.js
vendored
17
dist/bundle.es.js
vendored
|
@ -2406,29 +2406,34 @@ const makeSelectMyStreamUrlsForPage = (page = 1) => reselect.createSelector(sele
|
||||||
|
|
||||||
const selectMyStreamUrlsCount = reselect.createSelector(selectMyClaimUrisWithoutChannels, channels => channels.length);
|
const selectMyStreamUrlsCount = reselect.createSelector(selectMyClaimUrisWithoutChannels, channels => channels.length);
|
||||||
|
|
||||||
const makeSelectResolvedRecommendedContentForUri = (uri, size) => reselect.createSelector(makeSelectClaimForUri(uri), selectResolvedSearchResultsByQuery, makeSelectClaimIsNsfw(uri), (claim, resolvedResultsByQuery, isMature) => {
|
const makeSelectResolvedRecommendedContentForUri = (uri, size, claimId, claimName, claimTitle) => reselect.createSelector(makeSelectClaimForUri(uri), selectResolvedSearchResultsByQuery, makeSelectClaimIsNsfw(uri), (claim, resolvedResultsByQuery, isMature) => {
|
||||||
const atVanityURI = !uri.includes('#');
|
const atVanityURI = !uri.includes('#');
|
||||||
|
|
||||||
|
let currentUri;
|
||||||
let recommendedContent;
|
let recommendedContent;
|
||||||
|
let title;
|
||||||
if (claim) {
|
if (claim) {
|
||||||
// always grab full URL - this can change once search returns canonical
|
// always grab full URL - this can change once search returns canonical
|
||||||
const currentUri = buildURI({ streamClaimId: claim.claim_id, streamName: claim.name });
|
currentUri = buildURI({ streamClaimId: claim.claim_id, streamName: claim.name });
|
||||||
|
|
||||||
const { title } = claim.value;
|
const { title } = claim.value;
|
||||||
|
} else {
|
||||||
|
// for cases on mobile where the claim may not have been resolved ()
|
||||||
|
currentUri = buildURI({ streamClaimId: claimId, streamName: claimName });
|
||||||
|
title = claimTitle;
|
||||||
|
}
|
||||||
|
|
||||||
if (!title) {
|
if (!title) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const options = { related_to: claim.claim_id, size, isBackgroundSearch: false };
|
const options = { related_to: claim ? claim.claim_id : claimId, size, isBackgroundSearch: false };
|
||||||
|
|
||||||
const searchQuery = getSearchQueryString(title.replace(/\//, ' '), options);
|
const searchQuery = getSearchQueryString(claimTitle.replace(/\//, ' '), options);
|
||||||
let results = resolvedResultsByQuery[searchQuery];
|
let results = resolvedResultsByQuery[searchQuery];
|
||||||
if (results) {
|
if (results) {
|
||||||
results = results.filter(result => buildURI({ streamClaimId: result.claimId, streamName: result.name }) !== currentUri);
|
results = results.filter(result => buildURI({ streamClaimId: result.claimId, streamName: result.name }) !== currentUri);
|
||||||
recommendedContent = results;
|
recommendedContent = results;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return recommendedContent;
|
return recommendedContent;
|
||||||
});
|
});
|
||||||
|
|
|
@ -678,7 +678,13 @@ export const selectMyStreamUrlsCount = createSelector(
|
||||||
channels => channels.length
|
channels => channels.length
|
||||||
);
|
);
|
||||||
|
|
||||||
export const makeSelectResolvedRecommendedContentForUri = (uri: string, size: number) =>
|
export const makeSelectResolvedRecommendedContentForUri = (
|
||||||
|
uri: string,
|
||||||
|
size: number,
|
||||||
|
claimId: string,
|
||||||
|
claimName: string,
|
||||||
|
claimTitle: string
|
||||||
|
) =>
|
||||||
createSelector(
|
createSelector(
|
||||||
makeSelectClaimForUri(uri),
|
makeSelectClaimForUri(uri),
|
||||||
selectResolvedSearchResultsByQuery,
|
selectResolvedSearchResultsByQuery,
|
||||||
|
@ -686,12 +692,18 @@ export const makeSelectResolvedRecommendedContentForUri = (uri: string, size: nu
|
||||||
(claim, resolvedResultsByQuery, isMature) => {
|
(claim, resolvedResultsByQuery, isMature) => {
|
||||||
const atVanityURI = !uri.includes('#');
|
const atVanityURI = !uri.includes('#');
|
||||||
|
|
||||||
|
let currentUri;
|
||||||
let recommendedContent;
|
let recommendedContent;
|
||||||
|
let title;
|
||||||
if (claim) {
|
if (claim) {
|
||||||
// always grab full URL - this can change once search returns canonical
|
// always grab full URL - this can change once search returns canonical
|
||||||
const currentUri = buildURI({ streamClaimId: claim.claim_id, streamName: claim.name });
|
currentUri = buildURI({ streamClaimId: claim.claim_id, streamName: claim.name });
|
||||||
|
|
||||||
const { title } = claim.value;
|
const { title } = claim.value;
|
||||||
|
} else {
|
||||||
|
// for cases on mobile where the claim may not have been resolved ()
|
||||||
|
currentUri = buildURI({ streamClaimId: claimId, streamName: claimName });
|
||||||
|
title = claimTitle;
|
||||||
|
}
|
||||||
|
|
||||||
if (!title) {
|
if (!title) {
|
||||||
return;
|
return;
|
||||||
|
@ -701,9 +713,9 @@ export const makeSelectResolvedRecommendedContentForUri = (uri: string, size: nu
|
||||||
related_to?: string,
|
related_to?: string,
|
||||||
nsfw?: boolean,
|
nsfw?: boolean,
|
||||||
isBackgroundSearch?: boolean,
|
isBackgroundSearch?: boolean,
|
||||||
} = { related_to: claim.claim_id, size, isBackgroundSearch: false };
|
} = { related_to: claim ? claim.claim_id : claimId, size, isBackgroundSearch: false };
|
||||||
|
|
||||||
const searchQuery = getSearchQueryString(title.replace(/\//, ' '), options);
|
const searchQuery = getSearchQueryString(claimTitle.replace(/\//, ' '), options);
|
||||||
let results = resolvedResultsByQuery[searchQuery];
|
let results = resolvedResultsByQuery[searchQuery];
|
||||||
if (results) {
|
if (results) {
|
||||||
results = results.filter(
|
results = results.filter(
|
||||||
|
@ -712,7 +724,6 @@ export const makeSelectResolvedRecommendedContentForUri = (uri: string, size: nu
|
||||||
);
|
);
|
||||||
recommendedContent = results;
|
recommendedContent = results;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return recommendedContent;
|
return recommendedContent;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue