Resolved search updates #273

Merged
akinwale merged 7 commits from resolved-search into master 2020-02-10 12:04:35 +01:00
3 changed files with 73 additions and 2 deletions
Showing only changes of commit 6ef2f9dde9 - Show all commits

33
dist/bundle.es.js vendored
View file

@ -2277,6 +2277,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, (claim, resolvedResultsByQuery) => {
const atVanityURI = !uri.includes('#');
let recommendedContent;
if (claim) {
// always grab full URL - this can change once search returns canonical
const currentUri = buildURI({ streamClaimId: claim.claim_id, streamName: claim.name });
const { title } = claim.value;
if (!title) {
return;
}
const searchQuery = getSearchQueryString(title.replace(/\//, ' '), { size }, undefined, {
related_to: claim.claim_id
});
let results = resolvedResultsByQuery[searchQuery];
if (results) {
results = results.filter(result => buildURI({ streamClaimId: result.claimId, streamName: result.name }) !== currentUri);
recommendedContent = results;
}
}
return recommendedContent;
});
function numberWithCommas(x) { function numberWithCommas(x) {
var parts = x.toString().split('.'); var parts = x.toString().split('.');
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ','); parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',');
@ -5091,7 +5119,9 @@ const searchReducer = handleActions({
return _extends$c({}, state, { return _extends$c({}, state, {
searching: false, searching: false,
resolvedResultsByQuery: Object.assign({}, state.resolvedResultsByQuery, { [query]: results }) resolvedResultsByQuery: Object.assign({}, state.resolvedResultsByQuery, {
[query]: results
})
}); });
}, },
@ -5736,6 +5766,7 @@ exports.makeSelectPermanentUrlForUri = makeSelectPermanentUrlForUri;
exports.makeSelectPublishFormValue = makeSelectPublishFormValue; exports.makeSelectPublishFormValue = makeSelectPublishFormValue;
exports.makeSelectQueryWithOptions = makeSelectQueryWithOptions; exports.makeSelectQueryWithOptions = makeSelectQueryWithOptions;
exports.makeSelectRecommendedContentForUri = makeSelectRecommendedContentForUri; exports.makeSelectRecommendedContentForUri = makeSelectRecommendedContentForUri;
exports.makeSelectResolvedRecommendedContentForUri = makeSelectResolvedRecommendedContentForUri;
exports.makeSelectResolvedSearchResults = makeSelectResolvedSearchResults; exports.makeSelectResolvedSearchResults = makeSelectResolvedSearchResults;
exports.makeSelectSearchDownloadUrlsCount = makeSelectSearchDownloadUrlsCount; exports.makeSelectSearchDownloadUrlsCount = makeSelectSearchDownloadUrlsCount;
exports.makeSelectSearchDownloadUrlsForPage = makeSelectSearchDownloadUrlsForPage; exports.makeSelectSearchDownloadUrlsForPage = makeSelectSearchDownloadUrlsForPage;

View file

@ -184,6 +184,7 @@ export {
makeSelectOmittedCountForChannel, makeSelectOmittedCountForChannel,
makeSelectClaimIsNsfw, makeSelectClaimIsNsfw,
makeSelectRecommendedContentForUri, makeSelectRecommendedContentForUri,
makeSelectResolvedRecommendedContentForUri,
makeSelectFirstRecommendedFileForUri, makeSelectFirstRecommendedFileForUri,
makeSelectChannelForClaimUri, makeSelectChannelForClaimUri,
makeSelectClaimIsPending, makeSelectClaimIsPending,

View file

@ -1,6 +1,9 @@
// @flow // @flow
import { normalizeURI, buildURI, parseURI } from 'lbryURI'; import { normalizeURI, buildURI, parseURI } from 'lbryURI';
import { selectSearchUrisByQuery } from 'redux/selectors/search'; import {
selectResolvedSearchResultsByQuery,
selectSearchUrisByQuery,
} from 'redux/selectors/search';
import { selectSupportsByOutpoint } from 'redux/selectors/wallet'; import { selectSupportsByOutpoint } from 'redux/selectors/wallet';
import { createSelector } from 'reselect'; import { createSelector } from 'reselect';
import { isClaimNsfw, createNormalizedClaimSearchKey } from 'util/claim'; import { isClaimNsfw, createNormalizedClaimSearchKey } from 'util/claim';
@ -639,3 +642,39 @@ export const selectMyStreamUrlsCount = createSelector(
selectMyClaimUrisWithoutChannels, selectMyClaimUrisWithoutChannels,
channels => channels.length channels => channels.length
); );
export const makeSelectResolvedRecommendedContentForUri = (uri: string, size: number) =>
createSelector(
makeSelectClaimForUri(uri),
selectResolvedSearchResultsByQuery,
(claim, resolvedResultsByQuery) => {
const atVanityURI = !uri.includes('#');
let recommendedContent;
if (claim) {
// always grab full URL - this can change once search returns canonical
const currentUri = buildURI({ streamClaimId: claim.claim_id, streamName: claim.name });
const { title } = claim.value;
if (!title) {
return;
}
const searchQuery = getSearchQueryString(title.replace(/\//, ' '), { size }, undefined, {
related_to: claim.claim_id,
});
let results = resolvedResultsByQuery[searchQuery];
if (results) {
results = results.filter(
result =>
buildURI({ streamClaimId: result.claimId, streamName: result.name }) !== currentUri
);
recommendedContent = results;
}
}
return recommendedContent;
}
);