feat: episode selection

This commit is contained in:
Adrian Castro
2024-02-18 15:54:04 +01:00
parent 5032bcd77b
commit 45a61a67ea
2 changed files with 25 additions and 9 deletions

View File

@@ -25,15 +25,25 @@ export default function LoadingScreenWrapper() {
const data = params.data
? (JSON.parse(params.data as string) as ItemData)
: null;
return <LoadingScreen sourceId={sourceId} data={data} />;
const seasonData = params.seasonData
? (JSON.parse(params.seasonData as string) as {
season: number;
episode: number;
})
: null;
return (
<LoadingScreen sourceId={sourceId} data={data} seasonData={seasonData} />
);
}
function LoadingScreen({
sourceId,
data,
seasonData,
}: {
sourceId: string | undefined;
data: ItemData | null;
seasonData: { season: number; episode: number } | null;
}) {
const router = useRouter();
const [eventLog, setEventLog] = useState<Event[]>([]);
@@ -60,8 +70,8 @@ function LoadingScreen({
let episode: number | undefined;
if (type === "tv") {
// season = <chosen by user / continue watching> ?? undefined;
// episode = <chosen by user / continue watching> ?? undefined;
season = seasonData?.season ?? undefined;
episode = seasonData?.episode ?? undefined;
}
const scrapeMedia = transformSearchResultToScrapeMedia(
@@ -100,7 +110,7 @@ function LoadingScreen({
};
void initialize();
}, [data, router, sourceId]);
}, [data, router, seasonData?.episode, seasonData?.season, sourceId]);
return (
<ScreenLayout

View File

@@ -14,7 +14,7 @@ export const SeasonEpisodeSelector = () => {
const data = usePlayerStore((state) => state.interface.data);
const seasonData = usePlayerStore((state) => state.interface.seasonData);
const { isTrue, on, off } = useBoolean();
const _router = useRouter();
const router = useRouter();
return data?.type === "movie" || !seasonData ? null : (
<View className="max-w-36 flex-1">
@@ -44,10 +44,16 @@ export const SeasonEpisodeSelector = () => {
title={episode.name}
onPress={() => {
off();
// router.push({
// pathname: "/videoPlayer/loading",
// params: { sourceID: source.id, data: JSON.stringify(data) },
// });
router.push({
pathname: "/videoPlayer/loading",
params: {
data: JSON.stringify(data),
seasonData: JSON.stringify({
season: seasonData.season_number,
episode: episode.episode_number,
}),
},
});
}}
className="max-w-16"
/>