Skip to content

Commit

Permalink
Fix seasons list when there is no items
Browse files Browse the repository at this point in the history
  • Loading branch information
zoriya committed Oct 29, 2023
1 parent 1373d0c commit 43a4a0e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
7 changes: 5 additions & 2 deletions front/packages/models/src/resources/show.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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 };
Expand Down
22 changes: 11 additions & 11 deletions front/packages/ui/src/details/season.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 />
Expand All @@ -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}` })),
},
});

Expand Down Expand Up @@ -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 && (
Expand Down

0 comments on commit 43a4a0e

Please sign in to comment.