Skip to content

Commit

Permalink
loading and mainvideolisting stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
sphinxrave committed Jun 29, 2024
1 parent fdfebdf commit 9e396a3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
25 changes: 10 additions & 15 deletions packages/react/src/components/common/Loading.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ export function Loading(
props: DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement> &
LoadingProps,
) {
const sizeCN = cn({
"text-sm": props.size === "sm",
"text-lg": props.size === "md",
"text-2xl": props.size === "lg",
"text-4xl": props.size === "xl",
});
// const sizeCN = cn({
// "text-sm": props.size === "sm",
// "text-lg": props.size === "md",
// "text-2xl": props.size === "lg",
// "text-4xl": props.size === "xl",
// });

if (props.error) return <ApiError error={props.error} />;

Expand Down Expand Up @@ -55,26 +55,21 @@ export function VirtuosoLoadingFooter({
const { t } = useTranslation();
const { loadMore, isLoading, autoload } = context || {};

const { ref, isIntersecting, entry } = useIntersectionObserver({
const { ref, isIntersecting } = useIntersectionObserver({
rootMargin: "-100px",
});

useEffect(() => {
console.log(isIntersecting, isLoading, autoload);
if (autoload && isIntersecting && !isLoading) {
loadMore?.();
if (autoload && isIntersecting && !isLoading && loadMore) {
loadMore();
}
}, [autoload, isIntersecting, isLoading, loadMore]);

return context?.isLoading ? (
<Loading {...context} />
) : context?.hasNextPage ? (
<Button
ref={ref}
variant="outline"
className="mt-4 w-full"
onClick={loadMore}
>
<Button ref={ref} variant="primary" className="mt-4" onClick={loadMore}>
{t("component.channelList.loadMore")}
</Button>
) : undefined;
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/components/video/MainVideoListing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export function MainVideoListing({
loadMore: fetchNextPage,
}}
components={
hasNextPage
hasNextPage && !isLoading
? {
Footer: VirtuosoLoadingFooter,
}
Expand Down

0 comments on commit 9e396a3

Please sign in to comment.