b3c4ce05fa
* Add pagination support to channel search * fix #605 - channelContent component - replace lighthouse.search() to doSearch() * #605 - Add pagination support to channel search - create ClaimListSearch component to support channel search instead of ClaimListDiscover * #605 - Add pagination support to channel search - fix lint errors & component naming error Co-authored-by: Kyle <kyle.mai@wiredcraft.com>
47 lines
1.4 KiB
JavaScript
47 lines
1.4 KiB
JavaScript
import { connect } from 'react-redux';
|
|
import { selectClaimsByUri } from 'redux/selectors/claims';
|
|
import {
|
|
selectIsSearching,
|
|
makeSelectSearchUrisForQuery,
|
|
makeSelectHasReachedMaxResultsLength,
|
|
} from 'redux/selectors/search';
|
|
import { getSearchQueryString } from 'util/query-params';
|
|
import { doSearch } from 'redux/actions/search';
|
|
import ClaimListSearch from './view';
|
|
import { doFetchViewCount } from 'lbryinc';
|
|
|
|
const select = (state, props) => {
|
|
const { searchKeyword, pageSize, claimId, showMature } = props;
|
|
const channel_id = encodeURIComponent(claimId);
|
|
const isBackgroundSearch = false;
|
|
const searchOptions = showMature
|
|
? {
|
|
channel_id,
|
|
isBackgroundSearch,
|
|
}
|
|
: {
|
|
channel_id,
|
|
size: pageSize,
|
|
nsfw: false,
|
|
isBackgroundSearch,
|
|
};
|
|
|
|
const searchQueryString = getSearchQueryString(searchKeyword, searchOptions);
|
|
const searchResult = makeSelectSearchUrisForQuery(searchQueryString)(state);
|
|
const searchResultLastPageReached = makeSelectHasReachedMaxResultsLength(searchQueryString)(state);
|
|
|
|
return {
|
|
claimsByUri: selectClaimsByUri(state),
|
|
loading: props.loading !== undefined ? props.loading : selectIsSearching(state),
|
|
searchOptions,
|
|
searchResult,
|
|
searchResultLastPageReached,
|
|
};
|
|
};
|
|
|
|
const perform = {
|
|
doFetchViewCount,
|
|
doSearch,
|
|
};
|
|
|
|
export default connect(select, perform)(ClaimListSearch);
|