mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
Fix initial placeholders on mobile lists
This commit is contained in:
parent
1d6d27c0ee
commit
b4281188d4
@ -30,7 +30,7 @@ const emulateGap = (
|
||||
gap: number,
|
||||
numColumns: number,
|
||||
index: number,
|
||||
itemsCount: number
|
||||
itemsCount: number,
|
||||
): ViewStyle => {
|
||||
let marginLeft = 0;
|
||||
let marginRight = 0;
|
||||
@ -107,7 +107,7 @@ export const InfiniteFetchList = <Data, Props, _, Kind extends number | string>(
|
||||
const placeholders = [...Array(count === 0 ? numColumns : count)].map(
|
||||
(_, i) => ({ id: `gen${i}`, isLoading: true }) as Data,
|
||||
);
|
||||
const data = isFetching ? [...(items || []), ...placeholders] : items;
|
||||
const data = isFetching || !items ? [...(items || []), ...placeholders] : items;
|
||||
|
||||
const List = nested ? (FlatList as unknown as typeof FlashList) : FlashList;
|
||||
|
||||
@ -122,7 +122,7 @@ export const InfiniteFetchList = <Data, Props, _, Kind extends number | string>(
|
||||
renderItem={({ item, index }) => (
|
||||
<View
|
||||
style={[
|
||||
emulateGap(layout.layout, gap, numColumns, index, data?.length ?? 0),
|
||||
emulateGap(layout.layout, gap, numColumns, index, data.length),
|
||||
layout.layout === "horizontal" && {
|
||||
width:
|
||||
size * (getItemType && getItemSize ? getItemSize(getItemType(item, index)) : 1),
|
||||
|
@ -33,7 +33,7 @@ export type Layout = {
|
||||
};
|
||||
|
||||
export type WithLoading<Item> =
|
||||
| (Item & { isLoading?: false })
|
||||
| (Item & { isLoading: false })
|
||||
| (Partial<Item> & { isLoading: true });
|
||||
|
||||
const isPage = <T = unknown,>(obj: unknown): obj is Page<T> =>
|
||||
|
Loading…
x
Reference in New Issue
Block a user