Merge pull request #72 from lbryio/vanity-related-content

fix: strip out related content properly on vanity uris
This commit is contained in:
Sean Yesmunt 2018-08-27 19:01:02 -04:00 committed by GitHub
commit feffbe966f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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) { var makeSelectRecommendedContentForUri = exports.makeSelectRecommendedContentForUri = function makeSelectRecommendedContentForUri(uri) {
return (0, _reselect.createSelector)(makeSelectClaimForUri(uri), _search.selectSearchUrisByQuery, function (claim, searchUrisByQuery) { 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) { if (claim) {
var title = claim.value.stream.metadata.title; var title = claim.value.stream.metadata.title;
var searchUris = searchUrisByQuery[title.replace(/\//, ' ')]; var searchUris = searchUrisByQuery[title.replace(/\//, ' ')];
if (searchUris) { 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) { searchUris = searchUris.filter(function (searchUri) {
return searchUri !== uri; return searchUri !== uri;
}); });

View file

@ -267,8 +267,9 @@ export const makeSelectRecommendedContentForUri = uri =>
makeSelectClaimForUri(uri), makeSelectClaimForUri(uri),
selectSearchUrisByQuery, selectSearchUrisByQuery,
(claim, searchUrisByQuery) => { (claim, searchUrisByQuery) => {
let recommendedContent; const atVanityURI = !uri.includes('#');
let recommendedContent;
if (claim) { if (claim) {
const { const {
value: { value: {
@ -279,6 +280,12 @@ export const makeSelectRecommendedContentForUri = uri =>
} = claim; } = claim;
let searchUris = searchUrisByQuery[title.replace(/\//, ' ')]; let searchUris = searchUrisByQuery[title.replace(/\//, ' ')];
if (searchUris) { 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); searchUris = searchUris.filter(searchUri => searchUri !== uri);
recommendedContent = searchUris; recommendedContent = searchUris;
} }