mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-31 20:24:27 -04:00
Fix item type calculation in lists
This commit is contained in:
parent
7b45b205a5
commit
5393f1bf97
@ -150,7 +150,7 @@ export const EpisodeList = <Props,>({
|
|||||||
divider
|
divider
|
||||||
Header={Header}
|
Header={Header}
|
||||||
headerProps={headerProps}
|
headerProps={headerProps}
|
||||||
getItemType={(item) => (item.firstOfSeason ? "withHeader" : "normal")}
|
getItemType={(item) => (!item || item.firstOfSeason ? "withHeader" : "normal")}
|
||||||
contentContainerStyle={pageStyle}
|
contentContainerStyle={pageStyle}
|
||||||
placeholderCount={5}
|
placeholderCount={5}
|
||||||
Render={({ item }) => {
|
Render={({ item }) => {
|
||||||
|
@ -195,6 +195,7 @@ const downloadIcon = (status: State["status"]) => {
|
|||||||
return Downloading;
|
return Downloading;
|
||||||
case "FAILED":
|
case "FAILED":
|
||||||
return ErrorIcon;
|
return ErrorIcon;
|
||||||
|
case "PENDING":
|
||||||
case "PAUSED":
|
case "PAUSED":
|
||||||
case "STOPPED":
|
case "STOPPED":
|
||||||
return NotStarted;
|
return NotStarted;
|
||||||
|
@ -30,7 +30,7 @@ import {
|
|||||||
} from "react";
|
} from "react";
|
||||||
import { FlatList, View, type ViewStyle } from "react-native";
|
import { FlatList, View, type ViewStyle } from "react-native";
|
||||||
import { ErrorView } from "./errors";
|
import { ErrorView } from "./errors";
|
||||||
import { EmptyView, type Layout, OfflineView, type WithLoading, addHeader } from "./fetch";
|
import { EmptyView, type Layout, OfflineView, addHeader } from "./fetch";
|
||||||
|
|
||||||
const emulateGap = (
|
const emulateGap = (
|
||||||
layout: "grid" | "vertical" | "horizontal",
|
layout: "grid" | "vertical" | "horizontal",
|
||||||
@ -90,7 +90,7 @@ export const InfiniteFetchList = <Data, Props, _, Kind extends number | string>(
|
|||||||
divider?: boolean | ComponentType;
|
divider?: boolean | ComponentType;
|
||||||
Header?: ComponentType<Props & { children: JSX.Element }> | ReactElement;
|
Header?: ComponentType<Props & { children: JSX.Element }> | ReactElement;
|
||||||
headerProps?: Props;
|
headerProps?: Props;
|
||||||
getItemType?: (item: WithLoading<Data>, index: number) => Kind;
|
getItemType?: (item: Data | null, index: number) => Kind;
|
||||||
getItemSize?: (kind: Kind) => number;
|
getItemSize?: (kind: Kind) => number;
|
||||||
fetchMore?: boolean;
|
fetchMore?: boolean;
|
||||||
nested?: boolean;
|
nested?: boolean;
|
||||||
@ -139,7 +139,7 @@ export const InfiniteFetchList = <Data, Props, _, Kind extends number | string>(
|
|||||||
)}
|
)}
|
||||||
data={data}
|
data={data}
|
||||||
horizontal={layout.layout === "horizontal"}
|
horizontal={layout.layout === "horizontal"}
|
||||||
keyExtractor={(item: any) => item.id}
|
keyExtractor={(item: any, index) => (item ? item.id : index)}
|
||||||
numColumns={layout.layout === "horizontal" ? 1 : numColumns}
|
numColumns={layout.layout === "horizontal" ? 1 : numColumns}
|
||||||
estimatedItemSize={size}
|
estimatedItemSize={size}
|
||||||
onEndReached={fetchMore ? fetchNextPage : undefined}
|
onEndReached={fetchMore ? fetchNextPage : undefined}
|
||||||
|
@ -33,7 +33,7 @@ import {
|
|||||||
} from "react";
|
} from "react";
|
||||||
import { type Stylable, nativeStyleToCss, useYoshiki, ysMap } from "yoshiki";
|
import { type Stylable, nativeStyleToCss, useYoshiki, ysMap } from "yoshiki";
|
||||||
import { ErrorView } from "./errors";
|
import { ErrorView } from "./errors";
|
||||||
import { EmptyView, type Layout, type WithLoading, addHeader } from "./fetch";
|
import { EmptyView, type Layout, addHeader } from "./fetch";
|
||||||
|
|
||||||
const InfiniteScroll = <Props,>({
|
const InfiniteScroll = <Props,>({
|
||||||
children,
|
children,
|
||||||
@ -167,7 +167,7 @@ export const InfiniteFetchList = <Data, _, HeaderProps, Kind extends number | st
|
|||||||
divider?: boolean | ComponentType;
|
divider?: boolean | ComponentType;
|
||||||
Header?: ComponentType<{ children: JSX.Element } & HeaderProps> | ReactElement;
|
Header?: ComponentType<{ children: JSX.Element } & HeaderProps> | ReactElement;
|
||||||
headerProps: HeaderProps;
|
headerProps: HeaderProps;
|
||||||
getItemType?: (item: WithLoading<Data>, index: number) => Kind;
|
getItemType?: (item: Data | null, index: number) => Kind;
|
||||||
getItemSize?: (kind: Kind) => number;
|
getItemSize?: (kind: Kind) => number;
|
||||||
fetchMore?: boolean;
|
fetchMore?: boolean;
|
||||||
contentContainerStyle?: ContentStyle;
|
contentContainerStyle?: ContentStyle;
|
||||||
|
@ -36,7 +36,7 @@ export const NewsList = () => {
|
|||||||
<InfiniteFetch
|
<InfiniteFetch
|
||||||
query={NewsList.query()}
|
query={NewsList.query()}
|
||||||
layout={{ ...ItemGrid.layout, layout: "horizontal" }}
|
layout={{ ...ItemGrid.layout, layout: "horizontal" }}
|
||||||
getItemType={(x, i) => (x.kind === "movie" || (x.isLoading && i % 2) ? "movie" : "episode")}
|
getItemType={(x, i) => (x?.kind === "movie" || (!x && i % 2) ? "movie" : "episode")}
|
||||||
getItemSize={(kind) => (kind === "episode" ? 2 : 1)}
|
getItemSize={(kind) => (kind === "episode" ? 2 : 1)}
|
||||||
empty={t("home.none")}
|
empty={t("home.none")}
|
||||||
Render={({ item }) => {
|
Render={({ item }) => {
|
||||||
|
@ -62,9 +62,7 @@ export const WatchlistList = () => {
|
|||||||
query={WatchlistList.query()}
|
query={WatchlistList.query()}
|
||||||
layout={{ ...ItemGrid.layout, layout: "horizontal" }}
|
layout={{ ...ItemGrid.layout, layout: "horizontal" }}
|
||||||
getItemType={(x, i) =>
|
getItemType={(x, i) =>
|
||||||
(x.kind === "show" && x.watchStatus?.nextEpisode) || (x.isLoading && i % 2)
|
(x?.kind === "show" && x.watchStatus?.nextEpisode) || (!x && i % 2) ? "episode" : "item"
|
||||||
? "episode"
|
|
||||||
: "item"
|
|
||||||
}
|
}
|
||||||
getItemSize={(kind) => (kind === "episode" ? 2 : 1)}
|
getItemSize={(kind) => (kind === "episode" ? 2 : 1)}
|
||||||
empty={t("home.none")}
|
empty={t("home.none")}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user