rename select selectors
This commit is contained in:
parent
b2386cc400
commit
1628cca2c1
3 changed files with 9 additions and 9 deletions
|
@ -3,7 +3,7 @@ import { withRouter } from 'react-router';
|
||||||
import { doSearch } from 'redux/actions/search';
|
import { doSearch } from 'redux/actions/search';
|
||||||
import {
|
import {
|
||||||
selectIsSearching,
|
selectIsSearching,
|
||||||
makeSelectSearchUris,
|
makeSelectSearchUrisForQuery,
|
||||||
selectSearchOptions,
|
selectSearchOptions,
|
||||||
makeSelectHasReachedMaxResultsLength,
|
makeSelectHasReachedMaxResultsLength,
|
||||||
} from 'redux/selectors/search';
|
} from 'redux/selectors/search';
|
||||||
|
@ -28,7 +28,7 @@ const select = (state, props) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const query = getSearchQueryString(urlQuery, searchOptions);
|
const query = getSearchQueryString(urlQuery, searchOptions);
|
||||||
const uris = makeSelectSearchUris(query)(state);
|
const uris = makeSelectSearchUrisForQuery(query)(state);
|
||||||
const hasReachedMaxResultsLength = makeSelectHasReachedMaxResultsLength(query)(state);
|
const hasReachedMaxResultsLength = makeSelectHasReachedMaxResultsLength(query)(state);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
import * as ACTIONS from 'constants/action_types';
|
import * as ACTIONS from 'constants/action_types';
|
||||||
import { SEARCH_OPTIONS } from 'constants/search';
|
import { SEARCH_OPTIONS } from 'constants/search';
|
||||||
import { buildURI, doResolveUris, batchActions, isURIValid, makeSelectClaimForUri } from 'lbry-redux';
|
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 handleFetchResponse from 'util/handle-fetch';
|
||||||
import { getSearchQueryString } from 'util/query-params';
|
import { getSearchQueryString } from 'util/query-params';
|
||||||
import { SIMPLE_SITE, SEARCH_SERVER_API } from 'config';
|
import { SIMPLE_SITE, SEARCH_SERVER_API } from 'config';
|
||||||
|
@ -48,7 +48,7 @@ export const doSearch = (rawQuery: string, searchOptions: SearchOptions) => (
|
||||||
const from = searchOptions.from;
|
const from = searchOptions.from;
|
||||||
|
|
||||||
// If we have already searched for something, we don't need to do anything
|
// 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 (urisForQuery && !!urisForQuery.length) {
|
||||||
if (!size || !from || from + size < urisForQuery.length) {
|
if (!size || !from || from + size < urisForQuery.length) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -27,7 +27,7 @@ export const selectSearchOptions: (state: State) => SearchOptions = createSelect
|
||||||
|
|
||||||
export const selectIsSearching: (state: State) => boolean = createSelector(selectState, (state) => state.searching);
|
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,
|
selectState,
|
||||||
(state) => state.resultsByQuery
|
(state) => state.resultsByQuery
|
||||||
);
|
);
|
||||||
|
@ -37,9 +37,9 @@ export const selectHasReachedMaxResultsLength: (state: State) => { [boolean]: Ar
|
||||||
(state) => state.hasReachedMaxResultsLength
|
(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
|
// replace statement below is kind of ugly, and repeated in doSearch action
|
||||||
createSelector(selectSearchUrisByQuery, (byQuery) => {
|
createSelector(selectSearchResultByQuery, (byQuery) => {
|
||||||
if (query) {
|
if (query) {
|
||||||
query = query.replace(/^lbry:\/\//i, '').replace(/\//, ' ');
|
query = query.replace(/^lbry:\/\//i, '').replace(/\//, ' ');
|
||||||
const normalizedQuery = createNormalizedSearchKey(query);
|
const normalizedQuery = createNormalizedSearchKey(query);
|
||||||
|
@ -61,7 +61,7 @@ export const makeSelectHasReachedMaxResultsLength = (query: string): ((state: St
|
||||||
export const makeSelectRecommendedContentForUri = (uri: string) =>
|
export const makeSelectRecommendedContentForUri = (uri: string) =>
|
||||||
createSelector(
|
createSelector(
|
||||||
makeSelectClaimForUri(uri),
|
makeSelectClaimForUri(uri),
|
||||||
selectSearchUrisByQuery,
|
selectSearchResultByQuery,
|
||||||
makeSelectClaimIsNsfw(uri),
|
makeSelectClaimIsNsfw(uri),
|
||||||
(claim, searchUrisByQuery, isMature) => {
|
(claim, searchUrisByQuery, isMature) => {
|
||||||
let recommendedContent;
|
let recommendedContent;
|
||||||
|
@ -95,7 +95,7 @@ export const makeSelectRecommendedContentForUri = (uri: string) =>
|
||||||
);
|
);
|
||||||
|
|
||||||
export const makeSelectRecommendedRecsysIdForClaimId = (claimId: string) =>
|
export const makeSelectRecommendedRecsysIdForClaimId = (claimId: string) =>
|
||||||
createSelector(makeSelectClaimForClaimId(claimId), selectSearchUrisByQuery, (claim, searchUrisByQuery) => {
|
createSelector(makeSelectClaimForClaimId(claimId), selectSearchResultByQuery, (claim, searchUrisByQuery) => {
|
||||||
// TODO: DRY this out.
|
// TODO: DRY this out.
|
||||||
let poweredBy;
|
let poweredBy;
|
||||||
if (claim) {
|
if (claim) {
|
||||||
|
|
Loading…
Reference in a new issue