paginates over search count rather than channel claim count #3271

Merged
jessopb merged 4 commits from fix-noMatureSearchPagination into master 2019-12-04 00:47:48 +01:00
4 changed files with 29 additions and 19 deletions
Showing only changes of commit f21925beab - Show all commits

View file

@ -887,5 +887,7 @@
"with lbry.tv to receive notifications related to new content.": "with lbry.tv to receive notifications related to new content.",
"An email was sent to %email%. Follow the link to %verify_text%. After, this page will update automatically.": "An email was sent to %email%. Follow the link to %verify_text%. After, this page will update automatically.",
"Your email preferences": "Your email preferences",
"allow you to receive notifications related to new content.": "allow you to receive notifications related to new content."
"allow you to receive notifications related to new content.": "allow you to receive notifications related to new content.",
"files": "files",
"Invalid claim ID %claimId%.": "Invalid claim ID %claimId%."
}

View file

@ -5,7 +5,7 @@ import {
makeSelectClaimsInChannelForPage,
makeSelectFetchingChannelClaims,
makeSelectClaimIsMine,
makeSelectTotalPagesForChannel,
makeSelectTotalPagesInChannelSearch,
selectChannelIsBlocked,
} from 'lbry-redux';
import { withRouter } from 'react-router';
@ -16,9 +16,9 @@ const select = (state, props) => {
const urlParams = new URLSearchParams(search);
const page = urlParams.get('page') || 0;
return {
claimsInChannel: makeSelectClaimsInChannelForPage(props.uri, page)(state),
pageOfClaimsInChannel: makeSelectClaimsInChannelForPage(props.uri, page)(state),
fetching: makeSelectFetchingChannelClaims(props.uri)(state),
totalPages: makeSelectTotalPagesForChannel(props.uri, PAGE_SIZE)(state),
totalPages: makeSelectTotalPagesInChannelSearch(props.uri, PAGE_SIZE)(state),
channelIsMine: makeSelectClaimIsMine(props.uri)(state),
channelIsBlocked: selectChannelIsBlocked(props.uri)(state),
};

View file

@ -12,7 +12,7 @@ type Props = {
totalPages: number,
fetching: boolean,
params: { page: number },
claimsInChannel: Array<StreamClaim>,
pageOfClaimsInChannel: Array<StreamClaim>,
channelIsBlocked: boolean,
channelIsMine: boolean,
fetchClaims: (string, number) => void,
@ -23,15 +23,14 @@ function ChannelContent(props: Props) {
const {
uri,
fetching,
claimsInChannel,
pageOfClaimsInChannel,
totalPages,
channelIsMine,
channelIsBlocked,
fetchClaims,
channelIsBlackListed,
} = props;
const hasContent = Boolean(claimsInChannel && claimsInChannel.length);
const hasContent = Boolean(pageOfClaimsInChannel && pageOfClaimsInChannel.length);
return (
<Fragment>
{fetching && !hasContent && (
@ -68,7 +67,7 @@ function ChannelContent(props: Props) {
{!channelIsMine && <HiddenNsfwClaims uri={uri} />}
{hasContent && !channelIsBlocked && !channelIsBlackListed && (
<ClaimList header={false} uris={claimsInChannel.map(claim => claim && claim.canonical_url)} />
<ClaimList header={false} uris={pageOfClaimsInChannel.map(claim => claim && claim.canonical_url)} />
)}
{!channelIsBlocked && !channelIsBlackListed && (

View file

@ -12,6 +12,7 @@ import { setSubscriptionLatest, doUpdateUnreadSubscriptions } from 'redux/action
import { makeSelectUnreadByChannel } from 'redux/selectors/subscriptions';
import {
ACTIONS,
MATURE_TAGS,
Lbry,
Lbryapi,
makeSelectFileInfoForUri,
@ -137,21 +138,28 @@ export function doSetPlayingUri(uri: ?string) {
}
export function doFetchClaimsByChannel(uri: string, page: number = 1, pageSize: number = PAGE_SIZE) {
return (dispatch: Dispatch) => {
dispatch({
type: ACTIONS.FETCH_CHANNEL_CLAIMS_STARTED,
data: { uri, page },
});
Lbry.claim_search({
return (dispatch: Dispatch, getState: GetState) => {
const state = getState();
const showMature = makeSelectClientSetting(SETTINGS.SHOW_MATURE)(state);
const params = {
channel: uri,
page,
page_size: pageSize,
valid_channel_signature: true,
order_by: ['release_time'],
}).then(result => {
const { items: claims, total_items: claimsInChannel, page: returnedPage } = result;
};
if (!showMature) {
params['not_tags'] = MATURE_TAGS;
}
dispatch({
type: ACTIONS.FETCH_CHANNEL_CLAIMS_STARTED,
data: { uri, page },
});
Lbry.claim_search(params).then(result => {
const { items: claims, page: returnedPage, total_items: claimsInChannel, total_pages: pageTotal } = result;
if (claims && claims.length) {
if (page === 1) {
const latest = claims[0];
@ -174,6 +182,7 @@ export function doFetchClaimsByChannel(uri: string, page: number = 1, pageSize:
claimsInChannel,
claims: claims || [],
page: returnedPage || undefined,
totalPages: pageTotal,
},
});
});