add pageSize prop to ClaimList

This commit is contained in:
Sean Yesmunt 2019-07-01 22:54:11 -04:00
parent f387f4c01f
commit 147e914ed8
3 changed files with 36 additions and 5 deletions

View file

@ -22,6 +22,7 @@ type Props = {
defaultSort?: boolean,
onScrollBottom?: any => void,
page?: number,
pageSize?: number,
// If using the default header, this is a unique ID needed to persist the state of the filter setting
persistedStorageKey?: string,
};
@ -39,6 +40,7 @@ export default function ClaimList(props: Props) {
header,
onScrollBottom,
page,
pageSize,
} = props;
const [currentSort, setCurrentSort] = usePersistedState(persistedStorageKey, SORT_NEW);
const hasUris = uris && !!uris.length;
@ -51,12 +53,11 @@ export default function ClaimList(props: Props) {
const urisLength = uris && uris.length;
useEffect(() => {
function handleScroll(e) {
if (onScrollBottom) {
if (pageSize && onScrollBottom) {
const x = document.querySelector(`.${MAIN_WRAPPER_CLASS}`);
if (x && window.scrollY + window.innerHeight >= x.offsetHeight) {
// fix this
if (!loading && urisLength > 19) {
if (!loading && urisLength >= pageSize) {
onScrollBottom();
}
}

View file

@ -156,6 +156,7 @@ function ClaimListDiscover(props: Props) {
headerAltControls={meta}
onScrollBottom={() => setPage(page + 1)}
page={page}
pageSize={PAGE_SIZE}
/>
{loading && page > 1 && new Array(PAGE_SIZE).fill(1).map((x, i) => <ClaimPreview key={i} placeholder />)}

View file

@ -427,5 +427,34 @@
"Error message": "Error message",
"Error data": "Error data",
"Error": "Error",
"We're sorry that LBRY has encountered an error. This has been reported and we will investigate the problem.": "We're sorry that LBRY has encountered an error. This has been reported and we will investigate the problem."
}
"We're sorry that LBRY has encountered an error. This has been reported and we will investigate the problem.": "We're sorry that LBRY has encountered an error. This has been reported and we will investigate the problem.",
"Customize": "Customize",
"Customize Your Homepage": "Customize Your Homepage",
"Tags You Follow": "Tags You Follow",
"Channels You Follow": "Channels You Follow",
"Everyone": "Everyone",
"This file is downloaded.": "This file is downloaded.",
"Featured content. Earn rewards for watching.": "Featured content. Earn rewards for watching.",
"You are subscribed to this channel.": "You are subscribed to this channel.",
"Remove from your library": "Remove from your library",
"View tag": "View tag",
"Customize Your Tags": "Customize Your Tags",
"Remove tag": "Remove tag",
"Add tag": "Add tag",
"The better your tags are, the easier it will be for people to discover your content.": "The better your tags are, the easier it will be for people to discover your content.",
"No tags added": "No tags added",
"My description for this and that": "My description for this and that",
"Choose a thumbnail": "Choose a thumbnail",
"Take a snapshot from your video": "Take a snapshot from your video",
"Upload your thumbnail to": "Upload your thumbnail to",
"Add a price to this file": "Add a price to this file",
"Additional Options": "Additional Options",
"A URL is required": "A URL is required",
"A name is required": "A name is required",
"The updates will take a few minutes to appear for other LBRY users. Until then it will be listed as \"pending\" under your published files.": "The updates will take a few minutes to appear for other LBRY users. Until then it will be listed as \"pending\" under your published files.",
"Your Publishes": "Your Publishes",
"New Publish": "New Publish",
"Your Library": "Your Library",
"This will appear as a tip for \"Original LBRY porn - Nude Hot Girl masturbates FREE\".": "This will appear as a tip for \"Original LBRY porn - Nude Hot Girl masturbates FREE\".",
"You sent 25 LBC as a tip, Mahalo!": "You sent 25 LBC as a tip, Mahalo!"
}