rename select selectors

This commit is contained in:
zeppi 2021-08-13 12:44:26 -04:00
parent b2386cc400
commit 1628cca2c1
3 changed files with 9 additions and 9 deletions

View file

@ -3,7 +3,7 @@ import { withRouter } from 'react-router';
import { doSearch } from 'redux/actions/search';
import {
selectIsSearching,
makeSelectSearchUris,
makeSelectSearchUrisForQuery,
selectSearchOptions,
makeSelectHasReachedMaxResultsLength,
} from 'redux/selectors/search';
@ -28,7 +28,7 @@ const select = (state, props) => {
};
const query = getSearchQueryString(urlQuery, searchOptions);
const uris = makeSelectSearchUris(query)(state);
const uris = makeSelectSearchUrisForQuery(query)(state);
const hasReachedMaxResultsLength = makeSelectHasReachedMaxResultsLength(query)(state);
return {

View file

@ -2,7 +2,7 @@
import * as ACTIONS from 'constants/action_types';
import { SEARCH_OPTIONS } from 'constants/search';
import { buildURI, doResolveUris, batchActions, isURIValid, makeSelectClaimForUri } from 'lbry-redux';
import { makeSelectSearchUris, selectSearchValue } from 'redux/selectors/search';
import { makeSelectSearchUrisForQuery, selectSearchValue } from 'redux/selectors/search';
import handleFetchResponse from 'util/handle-fetch';
import { getSearchQueryString } from 'util/query-params';
import { SIMPLE_SITE, SEARCH_SERVER_API } from 'config';
@ -48,7 +48,7 @@ export const doSearch = (rawQuery: string, searchOptions: SearchOptions) => (
const from = searchOptions.from;
// If we have already searched for something, we don't need to do anything
const urisForQuery = makeSelectSearchUris(queryWithOptions)(state);
const urisForQuery = makeSelectSearchUrisForQuery(queryWithOptions)(state);
if (urisForQuery && !!urisForQuery.length) {
if (!size || !from || from + size < urisForQuery.length) {
return;

View file

@ -27,7 +27,7 @@ export const selectSearchOptions: (state: State) => SearchOptions = createSelect
export const selectIsSearching: (state: State) => boolean = createSelector(selectState, (state) => state.searching);
export const selectSearchUrisByQuery: (state: State) => { [string]: Array<string> } = createSelector(
export const selectSearchResultByQuery: (state: State) => { [string]: Array<string> } = createSelector(
selectState,
(state) => state.resultsByQuery
);
@ -37,9 +37,9 @@ export const selectHasReachedMaxResultsLength: (state: State) => { [boolean]: Ar
(state) => state.hasReachedMaxResultsLength
);
export const makeSelectSearchUris = (query: string): ((state: State) => Array<string>) =>
export const makeSelectSearchUrisForQuery = (query: string): ((state: State) => Array<string>) =>
// replace statement below is kind of ugly, and repeated in doSearch action
createSelector(selectSearchUrisByQuery, (byQuery) => {
createSelector(selectSearchResultByQuery, (byQuery) => {
if (query) {
query = query.replace(/^lbry:\/\//i, '').replace(/\//, ' ');
const normalizedQuery = createNormalizedSearchKey(query);
@ -61,7 +61,7 @@ export const makeSelectHasReachedMaxResultsLength = (query: string): ((state: St
export const makeSelectRecommendedContentForUri = (uri: string) =>
createSelector(
makeSelectClaimForUri(uri),
selectSearchUrisByQuery,
selectSearchResultByQuery,
makeSelectClaimIsNsfw(uri),
(claim, searchUrisByQuery, isMature) => {
let recommendedContent;
@ -95,7 +95,7 @@ export const makeSelectRecommendedContentForUri = (uri: string) =>
);
export const makeSelectRecommendedRecsysIdForClaimId = (claimId: string) =>
createSelector(makeSelectClaimForClaimId(claimId), selectSearchUrisByQuery, (claim, searchUrisByQuery) => {
createSelector(makeSelectClaimForClaimId(claimId), selectSearchResultByQuery, (claim, searchUrisByQuery) => {
// TODO: DRY this out.
let poweredBy;
if (claim) {