mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-31 04:04:21 -04:00
Show list headers on error
This commit is contained in:
parent
ca1d2dd16f
commit
3b98263fbc
@ -119,7 +119,7 @@ export const InfiniteFetch = <Data,>({
|
|||||||
});
|
});
|
||||||
const grid = layout.numColumns !== 1;
|
const grid = layout.numColumns !== 1;
|
||||||
|
|
||||||
if (error) return <ErrorView error={error} />;
|
if (error) return addHeader(Header, <ErrorView error={error} />);
|
||||||
if (empty && items && items.length === 0) {
|
if (empty && items && items.length === 0) {
|
||||||
if (typeof empty !== "string") return empty;
|
if (typeof empty !== "string") return empty;
|
||||||
return <EmptyView message={empty} />;
|
return <EmptyView message={empty} />;
|
||||||
@ -147,14 +147,20 @@ export const InfiniteFetch = <Data,>({
|
|||||||
))}
|
))}
|
||||||
</InfiniteScroll>
|
</InfiniteScroll>
|
||||||
);
|
);
|
||||||
|
return addHeader(Header, list);
|
||||||
|
};
|
||||||
|
|
||||||
if (!Header) return list;
|
const addHeader = (
|
||||||
|
Header: ComponentType<{ children: JSX.Element }> | ReactElement | undefined,
|
||||||
|
children: ReactElement,
|
||||||
|
) => {
|
||||||
|
if (!Header) return children;
|
||||||
return typeof Header === "function" ? (
|
return typeof Header === "function" ? (
|
||||||
<Header>{list}</Header>
|
<Header>{children}</Header>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
{Header}
|
{Header}
|
||||||
{list}
|
{children}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user