resolved related tweak (#290)

* handle cases where no claim object is present
* fix variable
* update bundle
* get the title properly
This commit is contained in:
Akinwale Ariwodola 2020-03-17 21:54:34 +01:00 committed by GitHub
parent 211e0830be
commit 2f896bac53
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 51 additions and 35 deletions

33
dist/bundle.es.js vendored
View file

@ -2406,28 +2406,33 @@ const makeSelectMyStreamUrlsForPage = (page = 1) => reselect.createSelector(sele
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('#');
let currentUri;
let recommendedContent;
let title;
if (claim) {
// 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 });
title = claim.value ? claim.value.title : null;
} else {
// for cases on mobile where the claim may not have been resolved ()
currentUri = buildURI({ streamClaimId: claimId, streamName: claimName });
title = claimTitle;
}
const { title } = claim.value;
if (!title) {
return;
}
if (!title) {
return;
}
const options = { related_to: claim ? claim.claim_id : claimId, size, isBackgroundSearch: false };
const options = { related_to: claim.claim_id, size, isBackgroundSearch: false };
const searchQuery = getSearchQueryString(title.replace(/\//, ' '), options);
let results = resolvedResultsByQuery[searchQuery];
if (results) {
results = results.filter(result => buildURI({ streamClaimId: result.claimId, streamName: result.name }) !== currentUri);
recommendedContent = results;
}
const searchQuery = getSearchQueryString(title.replace(/\//, ' '), options);
let results = resolvedResultsByQuery[searchQuery];
if (results) {
results = results.filter(result => buildURI({ streamClaimId: result.claimId, streamName: result.name }) !== currentUri);
recommendedContent = results;
}
return recommendedContent;

View file

@ -678,7 +678,13 @@ export const selectMyStreamUrlsCount = createSelector(
channels => channels.length
);
export const makeSelectResolvedRecommendedContentForUri = (uri: string, size: number) =>
export const makeSelectResolvedRecommendedContentForUri = (
uri: string,
size: number,
claimId: string,
claimName: string,
claimTitle: string
) =>
createSelector(
makeSelectClaimForUri(uri),
selectResolvedSearchResultsByQuery,
@ -686,32 +692,37 @@ export const makeSelectResolvedRecommendedContentForUri = (uri: string, size: nu
(claim, resolvedResultsByQuery, isMature) => {
const atVanityURI = !uri.includes('#');
let currentUri;
let recommendedContent;
let title;
if (claim) {
// 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 });
title = claim.value ? claim.value.title : null;
} else {
// for cases on mobile where the claim may not have been resolved ()
currentUri = buildURI({ streamClaimId: claimId, streamName: claimName });
title = claimTitle;
}
const { title } = claim.value;
if (!title) {
return;
}
if (!title) {
return;
}
const options: {
related_to?: string,
nsfw?: boolean,
isBackgroundSearch?: boolean,
} = { related_to: claim ? claim.claim_id : claimId, size, isBackgroundSearch: false };
const options: {
related_to?: string,
nsfw?: boolean,
isBackgroundSearch?: boolean,
} = { related_to: claim.claim_id, size, isBackgroundSearch: false };
const searchQuery = getSearchQueryString(title.replace(/\//, ' '), options);
let results = resolvedResultsByQuery[searchQuery];
if (results) {
results = results.filter(
result =>
buildURI({ streamClaimId: result.claimId, streamName: result.name }) !== currentUri
);
recommendedContent = results;
}
const searchQuery = getSearchQueryString(title.replace(/\//, ' '), options);
let results = resolvedResultsByQuery[searchQuery];
if (results) {
results = results.filter(
result =>
buildURI({ streamClaimId: result.claimId, streamName: result.name }) !== currentUri
);
recommendedContent = results;
}
return recommendedContent;