Fix seasons list when there is no items

This commit is contained in:
Zoe Roux 2023-10-29 21:34:48 +01:00
parent 1373d0ce26
commit 43a4a0e6ee
2 changed files with 16 additions and 13 deletions

View File

@ -35,7 +35,8 @@ export enum Status {
Planned = "Planned", Planned = "Planned",
} }
export const ShowP = withImages(ResourceP.extend({ export const ShowP = withImages(
ResourceP.extend({
/** /**
* The title of this show. * The title of this show.
*/ */
@ -84,7 +85,9 @@ export const ShowP = withImages(ResourceP.extend({
* The list of seasons of this show. * The list of seasons of this show.
*/ */
seasons: z.array(SeasonP).optional(), seasons: z.array(SeasonP).optional(),
}), "shows") }),
"shows",
)
.transform((x) => { .transform((x) => {
if (!x.thumbnail && x.poster) { if (!x.thumbnail && x.poster) {
x.thumbnail = { ...x.poster }; x.thumbnail = { ...x.poster };

View File

@ -72,7 +72,9 @@ export const SeasonHeader = ({
{isLoading ? <Skeleton /> : name} {isLoading ? <Skeleton /> : name}
</H6> </H6>
<Menu Trigger={IconButton} icon={MenuIcon} {...tooltip(t("show.jumpToSeason"))}> <Menu Trigger={IconButton} icon={MenuIcon} {...tooltip(t("show.jumpToSeason"))}>
{seasons?.map((x) => ( {seasons
?.filter((x) => x.episodesCount > 0)
.map((x) => (
<Menu.Item <Menu.Item
key={x.seasonNumber} key={x.seasonNumber}
label={`${x.seasonNumber}: ${x.name} (${x.episodesCount})`} label={`${x.seasonNumber}: ${x.name} (${x.episodesCount})`}
@ -96,10 +98,7 @@ SeasonHeader.query = (slug: string): QueryIdentifier<Season, SeasonProcessed> =>
infinite: { infinite: {
value: true, value: true,
map: (seasons) => map: (seasons) =>
seasons.reduce((acc, x) => { seasons.map((x) => ({ ...x, href: `/show/${slug}?season=${x.seasonNumber}` })),
if (x.episodesCount == 0) return acc;
return [...acc, { ...x, href: `/show/${slug}?season=${x.seasonNumber}` }];
}, [] as SeasonProcessed[]),
}, },
}); });
@ -134,6 +133,7 @@ export const EpisodeList = <Props,>({
const sea = item?.firstOfSeason const sea = item?.firstOfSeason
? seasons?.find((x) => x.seasonNumber === item.seasonNumber) ? seasons?.find((x) => x.seasonNumber === item.seasonNumber)
: null; : null;
console.log(sea, seasons);
return ( return (
<> <>
{item.firstOfSeason && ( {item.firstOfSeason && (