mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-01-18 00:58:03 +00:00
Some checks failed
🤖 Android APK Build / 🏗️ Build Android APK (push) Has been cancelled
🤖 iOS IPA Build / 🏗️ Build iOS IPA (push) Has been cancelled
🔒 Lockfile Consistency Check / 🔍 Check bun.lock and package.json consistency (push) Has been cancelled
🛡️ CodeQL Analysis / 🔎 Analyze with CodeQL (javascript-typescript) (push) Has been cancelled
🏷️🔀Merge Conflict Labeler / 🏷️ Labeling Merge Conflicts (push) Has been cancelled
🕒 Handle Stale Issues / 🗑️ Cleanup Stale Issues (push) Has been cancelled
69 lines
2.1 KiB
TypeScript
69 lines
2.1 KiB
TypeScript
import { getTvShowsApi } from "@jellyfin/sdk/lib/utils/api";
|
|
import { FlashList } from "@shopify/flash-list";
|
|
import { useQuery } from "@tanstack/react-query";
|
|
import { useAtom } from "jotai";
|
|
import type React from "react";
|
|
import { useTranslation } from "react-i18next";
|
|
import { View } from "react-native";
|
|
import { apiAtom, userAtom } from "@/providers/JellyfinProvider";
|
|
import ContinueWatchingPoster from "../ContinueWatchingPoster";
|
|
import { Text } from "../common/Text";
|
|
import { TouchableItemRouter } from "../common/TouchableItemRouter";
|
|
import { ItemCardText } from "../ItemCardText";
|
|
|
|
export const NextUp: React.FC<{ seriesId: string }> = ({ seriesId }) => {
|
|
const [user] = useAtom(userAtom);
|
|
const [api] = useAtom(apiAtom);
|
|
const { t } = useTranslation();
|
|
|
|
const { data: items } = useQuery({
|
|
queryKey: ["nextUp", seriesId],
|
|
queryFn: async () => {
|
|
if (!api) return null;
|
|
return (
|
|
await getTvShowsApi(api).getNextUp({
|
|
userId: user?.Id,
|
|
seriesId,
|
|
fields: ["MediaSourceCount"],
|
|
limit: 10,
|
|
})
|
|
).data.Items;
|
|
},
|
|
enabled: !!api && !!seriesId && !!user?.Id,
|
|
staleTime: 0,
|
|
});
|
|
|
|
if (!items?.length)
|
|
return (
|
|
<View className='px-4'>
|
|
<Text className='text-lg font-bold mb-2'>{t("item_card.next_up")}</Text>
|
|
<Text className='opacity-50'>{t("item_card.no_items_to_display")}</Text>
|
|
</View>
|
|
);
|
|
|
|
return (
|
|
<View>
|
|
<Text className='text-lg font-bold px-4 mb-2'>
|
|
{t("item_card.next_up")}
|
|
</Text>
|
|
<FlashList
|
|
contentContainerStyle={{ paddingLeft: 16 }}
|
|
horizontal
|
|
estimatedItemSize={172}
|
|
showsHorizontalScrollIndicator={false}
|
|
data={items}
|
|
renderItem={({ item, index }) => (
|
|
<TouchableItemRouter
|
|
item={item}
|
|
key={index}
|
|
className='flex flex-col w-44'
|
|
>
|
|
<ContinueWatchingPoster item={item} useEpisodePoster />
|
|
<ItemCardText item={item} />
|
|
</TouchableItemRouter>
|
|
)}
|
|
/>
|
|
</View>
|
|
);
|
|
};
|