fix: strip out related content properly on vanity uris

This commit is contained in:
Sean Yesmunt 2018-08-26 22:43:25 -04:00
parent ccda4117ee
commit b7ad41acba
2 changed files with 16 additions and 2 deletions

9
dist/bundle.js vendored
View file

@ -3312,13 +3312,20 @@ var makeSelectNsfwCountForChannel = exports.makeSelectNsfwCountForChannel = func
var makeSelectRecommendedContentForUri = exports.makeSelectRecommendedContentForUri = function makeSelectRecommendedContentForUri(uri) {
return (0, _reselect.createSelector)(makeSelectClaimForUri(uri), _search.selectSearchUrisByQuery, function (claim, searchUrisByQuery) {
var recommendedContent = void 0;
var atVanityURI = !uri.includes('#');
var recommendedContent = void 0;
if (claim) {
var title = claim.value.stream.metadata.title;
var searchUris = searchUrisByQuery[title.replace(/\//, ' ')];
if (searchUris) {
// If we are at a vanity uri, we can't do a uri match
// The first search result _should_ be the same as the claim a user is on
if (atVanityURI) {
searchUris = searchUris.slice(1);
}
searchUris = searchUris.filter(function (searchUri) {
return searchUri !== uri;
});

View file

@ -267,8 +267,9 @@ export const makeSelectRecommendedContentForUri = uri =>
makeSelectClaimForUri(uri),
selectSearchUrisByQuery,
(claim, searchUrisByQuery) => {
let recommendedContent;
const atVanityURI = !uri.includes('#');
let recommendedContent;
if (claim) {
const {
value: {
@ -279,6 +280,12 @@ export const makeSelectRecommendedContentForUri = uri =>
} = claim;
let searchUris = searchUrisByQuery[title.replace(/\//, ' ')];
if (searchUris) {
// If we are at a vanity uri, we can't do a uri match
// The first search result _should_ be the same as the claim a user is on
if (atVanityURI) {
searchUris = searchUris.slice(1);
}
searchUris = searchUris.filter(searchUri => searchUri !== uri);
recommendedContent = searchUris;
}