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

View File

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