Fix item types for android

This commit is contained in:
Zoe Roux 2023-09-09 22:07:55 +02:00
parent 31d9507033
commit 1641ba2898
No known key found for this signature in database
3 changed files with 9 additions and 1 deletions

View File

@ -121,9 +121,12 @@ export const EpisodeList = <Props,>({
divider
Header={Header}
headerProps={headerProps}
getItemType={(item) => (item.firstOfSeason ? "withHeader" : "normal")}
>
{(item) => {
const sea = item?.firstOfSeason ? seasons?.find((x) => x.seasonNumber === item.seasonNumber) : null;
const sea = item?.firstOfSeason
? seasons?.find((x) => x.seasonNumber === item.seasonNumber)
: null;
return (
<>
{item.firstOfSeason && (

View File

@ -35,6 +35,7 @@ export const InfiniteFetch = <Data, Props, _>({
divider = false,
Header,
headerProps,
getItemType,
...props
}: {
query: QueryIdentifier<_, Data>;
@ -50,6 +51,7 @@ export const InfiniteFetch = <Data, Props, _>({
divider?: boolean | ComponentType;
Header?: ComponentType<Props & { children: JSX.Element }> | ReactElement;
headerProps?: Props;
getItemType?: (item: Data, index: number) => string | number;
}): JSX.Element | null => {
if (!query.infinite) console.warn("A non infinite query was passed to an InfiniteFetch.");
@ -91,6 +93,7 @@ export const InfiniteFetch = <Data, Props, _>({
refreshing={isRefetching}
ItemSeparatorComponent={divider === true ? HR : divider || null}
ListHeaderComponent={Header}
getItemType={getItemType}
{...props}
/>
);

View File

@ -112,6 +112,7 @@ export const InfiniteFetch = <Data, _>({
empty,
divider: Divider = false,
Header,
getItemType,
...props
}: {
query: QueryIdentifier<_, Data>;
@ -126,6 +127,7 @@ export const InfiniteFetch = <Data, _>({
empty?: string | JSX.Element;
divider?: boolean | ComponentType;
Header?: ComponentType<{ children: JSX.Element }> | ReactElement;
getItemType?: (item: Data, index: number) => string | number;
}): JSX.Element | null => {
if (!query.infinite) console.warn("A non infinite query was passed to an InfiniteFetch.");