Use posters instead of thumbnails when no thumbnails exist

This commit is contained in:
Zoe Roux 2023-09-02 17:20:34 +02:00
parent 70466aba7e
commit b89617d125
No known key found for this signature in database
3 changed files with 125 additions and 104 deletions

View File

@ -25,7 +25,8 @@ import { Genre } from "./genre";
import { StudioP } from "./studio"; import { StudioP } from "./studio";
import { Status } from "./show"; import { Status } from "./show";
export const MovieP = ResourceP.merge(ImagesP).extend({ export const MovieP = ResourceP.merge(ImagesP)
.extend({
/** /**
* The title of this movie. * The title of this movie.
*/ */
@ -47,8 +48,7 @@ export const MovieP = ResourceP.merge(ImagesP).extend({
*/ */
tags: z.array(z.string()), tags: z.array(z.string()),
/** /**
/** * /** Is this movie not aired yet or finished?
* Is this movie not aired yet or finished?
*/ */
status: z.nativeEnum(Status), status: z.nativeEnum(Status),
/** /**
@ -82,7 +82,17 @@ export const MovieP = ResourceP.merge(ImagesP).extend({
*/ */
hls: z.string().transform(imageFn), hls: z.string().transform(imageFn),
}), }),
}); })
.transform((x) => {
if (!x.thumbnail && x.poster) {
x.thumbnail = { ...x.poster };
if (x.thumbnail) {
x.thumbnail.low = x.thumbnail.high;
x.thumbnail.medium = x.thumbnail.high;
}
}
return x;
});
/** /**
* A Movie type * A Movie type

View File

@ -35,7 +35,8 @@ export enum Status {
Planned = "Planned", Planned = "Planned",
} }
export const ShowP = ResourceP.merge(ImagesP).extend({ export const ShowP = ResourceP.merge(ImagesP)
.extend({
/** /**
* The title of this show. * The title of this show.
*/ */
@ -84,7 +85,17 @@ export const ShowP = ResourceP.merge(ImagesP).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(),
}); })
.transform((x) => {
if (!x.thumbnail && x.poster) {
x.thumbnail = { ...x.poster };
if (x.thumbnail) {
x.thumbnail.low = x.thumbnail.high;
x.thumbnail.medium = x.thumbnail.high;
}
}
return x;
});
/** /**
* A tv serie or an anime. * A tv serie or an anime.

View File

@ -46,7 +46,7 @@ export const ItemList = ({
<ImageBackground <ImageBackground
src={thumbnail} src={thumbnail}
alt={name} alt={name}
quality="low" quality="medium"
as={Link} as={Link}
href={href ?? ""} href={href ?? ""}
onFocus={() => setHovered((i) => i + 1)} onFocus={() => setHovered((i) => i + 1)}