Recommendations: factor out a selector for raw results
1606
This commit is contained in:
parent
05376490a8
commit
2edf1ca564
1 changed files with 20 additions and 11 deletions
|
@ -52,16 +52,31 @@ export const makeSelectHasReachedMaxResultsLength = (query: string): ((state: St
|
|||
return hasReachedMaxResultsLength[query];
|
||||
});
|
||||
|
||||
export const selectRecommendedContentRawForUri = createCachedSelector(
|
||||
(state, uri) => uri,
|
||||
selectClaimsByUri,
|
||||
selectShowMatureContent,
|
||||
selectClaimIsNsfwForUri, // (state, uri)
|
||||
selectSearchResultByQuery,
|
||||
(uri, claimsByUri, matureEnabled, isMature, searchUrisByQuery) => {
|
||||
const claim = claimsByUri[uri];
|
||||
if (claim?.value?.title) {
|
||||
const options = getRecommendationSearchOptions(matureEnabled, isMature, claim.claim_id);
|
||||
const normalizedSearchQuery = getRecommendationSearchKey(claim.value.title, options);
|
||||
return searchUrisByQuery[normalizedSearchQuery];
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
)((state, uri) => String(uri));
|
||||
|
||||
export const selectRecommendedContentForUri = createCachedSelector(
|
||||
(state, uri) => uri,
|
||||
selectHistory,
|
||||
selectRecommendedContentRawForUri, // (state, uri)
|
||||
selectClaimsByUri,
|
||||
selectShowMatureContent,
|
||||
selectMutedChannels,
|
||||
selectAllCostInfoByUri,
|
||||
selectSearchResultByQuery,
|
||||
selectClaimIsNsfwForUri, // (state, uri)
|
||||
(uri, history, claimsByUri, matureEnabled, blockedChannels, costInfoByUri, searchUrisByQuery, isMature) => {
|
||||
(uri, history, rawRecommendations, claimsByUri, blockedChannels, costInfoByUri) => {
|
||||
const claim = claimsByUri[uri];
|
||||
if (!claim) return;
|
||||
|
||||
|
@ -69,13 +84,7 @@ export const selectRecommendedContentForUri = createCachedSelector(
|
|||
// always grab the claimId - this value won't change for filtering
|
||||
const currentClaimId = claim.claim_id;
|
||||
|
||||
const { title } = claim.value;
|
||||
if (!title) return;
|
||||
|
||||
const options = getRecommendationSearchOptions(matureEnabled, isMature, claim.claim_id);
|
||||
const normalizedSearchQuery = getRecommendationSearchKey(title, options);
|
||||
|
||||
let searchResult = searchUrisByQuery[normalizedSearchQuery];
|
||||
const searchResult = rawRecommendations;
|
||||
|
||||
if (searchResult) {
|
||||
// Filter from recommended: The same claim and blocked channels
|
||||
|
|
Loading…
Reference in a new issue