Merge pull request #3271 from lbryio/fix-noMatureSearchPagination

paginates over search count rather than channel claim count
This commit is contained in:
jessopb 2019-12-03 18:47:48 -05:00 committed by GitHub
commit 3dcf2f0c21
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 38 additions and 30 deletions

View file

@ -127,7 +127,7 @@
"imagesloaded": "^4.1.4", "imagesloaded": "^4.1.4",
"json-loader": "^0.5.4", "json-loader": "^0.5.4",
"lbry-format": "https://github.com/lbryio/lbry-format.git", "lbry-format": "https://github.com/lbryio/lbry-format.git",
"lbry-redux": "lbryio/lbry-redux#c30889d3392b89ffffdb5beea8534f2aa0f76b19", "lbry-redux": "lbryio/lbry-redux#9b11cfed62af7f0f8eb6fa3c88a1f8d2cce46afc",
"lbryinc": "lbryio/lbryinc#2aedf5a188f028f61c45bc7ed0c747a2d4ae453a", "lbryinc": "lbryio/lbryinc#2aedf5a188f028f61c45bc7ed0c747a2d4ae453a",
"lint-staged": "^7.0.2", "lint-staged": "^7.0.2",
"localforage": "^1.7.1", "localforage": "^1.7.1",

View file

@ -887,6 +887,8 @@
"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.", "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", "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%."
"Suggested": "Suggested", "Suggested": "Suggested",
"%amountBehind% blocks behind": "%amountBehind% blocks behind", "%amountBehind% blocks behind": "%amountBehind% blocks behind",
"Startup Preferences": "Startup Preferences", "Startup Preferences": "Startup Preferences",
@ -898,9 +900,7 @@
"Checking your publishes...": "Checking your publishes...", "Checking your publishes...": "Checking your publishes...",
"Checking your publishes": "Checking your publishes", "Checking your publishes": "Checking your publishes",
"Checking for channels": "Checking for channels", "Checking for channels": "Checking for channels",
"files": "files",
"Error Starting Up": "Error Starting Up", "Error Starting Up": "Error Starting Up",
"Reach out to hello@lbry.com for help, or check out %help_link%.": "Reach out to hello@lbry.com for help, or check out %help_link%.", "Reach out to hello@lbry.com for help, or check out %help_link%.": "Reach out to hello@lbry.com for help, or check out %help_link%.",
"You're not following any tags. Smash that %customize% button!": "You're not following any tags. Smash that %customize% button!", "You're not following any tags. Smash that %customize% button!": "You're not following any tags. Smash that %customize% button!",
"customize": "customize" "customize": "customize"
}

View file

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

View file

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

View file

@ -1,23 +1,23 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { makeSelectNsfwCountForChannel, makeSelectNsfwCountFromUris, parseURI } from 'lbry-redux'; import { makeSelectNsfwCountFromUris, makeSelectOmittedCountForChannel, parseURI } from 'lbry-redux';
import { selectShowMatureContent } from 'redux/selectors/settings'; import { selectShowMatureContent } from 'redux/selectors/settings';
import HiddenNsfwClaims from './view'; import HiddenNsfwClaims from './view';
const select = (state, props) => { const select = (state, props) => {
const { uri, uris } = props; const { uri, uris } = props;
let numberOfNsfwClaims; let numberOfHiddenClaims;
if (uri) { if (uri) {
const { isChannel } = parseURI(uri); const { isChannel } = parseURI(uri);
numberOfNsfwClaims = isChannel numberOfHiddenClaims = isChannel
? makeSelectNsfwCountForChannel(uri)(state) ? makeSelectOmittedCountForChannel(uri)(state)
: makeSelectNsfwCountFromUris([uri])(state); : makeSelectNsfwCountFromUris([uri])(state);
} else if (uris) { } else if (uris) {
numberOfNsfwClaims = makeSelectNsfwCountFromUris(uris)(state); numberOfHiddenClaims = makeSelectNsfwCountFromUris(uris)(state);
} }
return { return {
numberOfNsfwClaims, numberOfHiddenClaims,
obscureNsfw: !selectShowMatureContent(state), obscureNsfw: !selectShowMatureContent(state),
}; };
}; };

View file

@ -3,19 +3,19 @@ import React from 'react';
import Button from 'component/button'; import Button from 'component/button';
type Props = { type Props = {
numberOfNsfwClaims: number, numberOfHiddenClaims: number,
obscureNsfw: boolean, obscureNsfw: boolean,
className: ?string, className: ?string,
}; };
export default (props: Props) => { export default (props: Props) => {
const { numberOfNsfwClaims, obscureNsfw } = props; const { numberOfHiddenClaims, obscureNsfw } = props;
return ( return (
obscureNsfw && obscureNsfw &&
Boolean(numberOfNsfwClaims) && ( Boolean(numberOfHiddenClaims) && (
<div className="section--padded section__subtitle"> <div className="section--padded section__subtitle">
{numberOfNsfwClaims} {numberOfNsfwClaims > 1 ? __('files') : __('file')} {__('hidden due to your')}{' '} {numberOfHiddenClaims} {numberOfHiddenClaims > 1 ? __('files') : __('file')} {__('hidden due to your')}{' '}
<Button button="link" navigate="/$/settings" label={__('content viewing preferences')} />. <Button button="link" navigate="/$/settings" label={__('content viewing preferences')} />.
</div> </div>
) )

View file

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