mirror of
https://github.com/zoriya/Kyoo.git
synced 2026-05-27 09:32:35 -04:00
Clean up kind handling in the front
This commit is contained in:
@@ -23,7 +23,6 @@ import {
|
||||
QueryPage,
|
||||
LibraryItem,
|
||||
LibraryItemP,
|
||||
ItemKind,
|
||||
getDisplayDate,
|
||||
} from "@kyoo/models";
|
||||
import { ComponentProps, useState } from "react";
|
||||
@@ -47,16 +46,16 @@ export const itemMap = (
|
||||
isLoading: item.isLoading,
|
||||
slug: item.slug,
|
||||
name: item.name,
|
||||
subtitle: item.kind !== ItemKind.Collection ? getDisplayDate(item) : undefined,
|
||||
subtitle: item.kind !== "collection" ? getDisplayDate(item) : undefined,
|
||||
href: item.href,
|
||||
poster: item.poster,
|
||||
thumbnail: item.thumbnail,
|
||||
watchStatus: item.kind !== ItemKind.Collection ? item.watchStatus?.status ?? null : null,
|
||||
type: item.kind.toLowerCase() as any,
|
||||
watchStatus: item.kind !== "collection" ? item.watchStatus?.status ?? null : null,
|
||||
type: item.kind,
|
||||
watchPercent:
|
||||
item.kind !== ItemKind.Collection ? item.watchStatus?.watchedPercent ?? null : null,
|
||||
item.kind !== "collection" ? item.watchStatus?.watchedPercent ?? null : null,
|
||||
unseenEpisodesCount:
|
||||
item.kind === ItemKind.Show
|
||||
item.kind === "show"
|
||||
? item.watchStatus?.unseenEpisodesCount ?? item.episodesCount!
|
||||
: null,
|
||||
};
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
import {
|
||||
Collection,
|
||||
CollectionP,
|
||||
ItemKind,
|
||||
LibraryItem,
|
||||
LibraryItemP,
|
||||
QueryIdentifier,
|
||||
@@ -161,20 +160,20 @@ export const CollectionPage: QueryPage<{ slug: string }> = ({ slug }) => {
|
||||
<ItemDetails
|
||||
isLoading={x.isLoading as any}
|
||||
slug={x.slug}
|
||||
type={x.kind?.toLowerCase() as any}
|
||||
type={x.kind}
|
||||
name={x.name}
|
||||
tagline={"tagline" in x ? x.tagline : null}
|
||||
overview={x.overview}
|
||||
poster={x.poster}
|
||||
subtitle={x.kind !== ItemKind.Collection && !x.isLoading ? getDisplayDate(x) : undefined}
|
||||
subtitle={x.kind !== "collection" && !x.isLoading ? getDisplayDate(x) : undefined}
|
||||
genres={"genres" in x ? x.genres : null}
|
||||
href={x.href}
|
||||
playHref={x.kind !== ItemKind.Collection && !x.isLoading ? x.playHref : undefined}
|
||||
playHref={x.kind !== "collection" && !x.isLoading ? x.playHref : undefined}
|
||||
watchStatus={
|
||||
!x.isLoading && x.kind !== ItemKind.Collection ? x.watchStatus?.status ?? null : null
|
||||
!x.isLoading && x.kind !== "collection" ? x.watchStatus?.status ?? null : null
|
||||
}
|
||||
unseenEpisodesCount={
|
||||
x.kind === ItemKind.Show ? x.watchStatus?.unseenEpisodesCount ?? x.episodesCount! : null
|
||||
x.kind === "show" ? x.watchStatus?.unseenEpisodesCount ?? x.episodesCount! : null
|
||||
}
|
||||
{...css({ marginX: ItemGrid.layout.gap })}
|
||||
/>
|
||||
|
||||
@@ -37,7 +37,7 @@ import { percent, rem, Stylable, Theme, useYoshiki } from "yoshiki/native";
|
||||
import { KyooImage, WatchStatusV } from "@kyoo/models";
|
||||
import { ItemProgress } from "../browse/grid";
|
||||
import { EpisodesContext } from "../components/context-menus";
|
||||
import { useRef, useState } from "react";
|
||||
import { useState } from "react";
|
||||
|
||||
export const episodeDisplayNumber = (
|
||||
episode: {
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { Genre, ItemKind, QueryPage } from "@kyoo/models";
|
||||
import { Genre, QueryPage } from "@kyoo/models";
|
||||
import { Fetch } from "../fetch";
|
||||
import { Header } from "./header";
|
||||
import { DefaultLayout } from "../layout";
|
||||
@@ -40,7 +40,7 @@ export const HomePage: QueryPage<{}, Genre> = ({ randomItems }) => {
|
||||
tagline={"tagline" in x ? x.tagline : null}
|
||||
overview={x.overview}
|
||||
thumbnail={x.thumbnail}
|
||||
link={x.kind !== ItemKind.Collection && !x.isLoading ? x.playHref : undefined}
|
||||
link={x.kind !== "collection" && !x.isLoading ? x.playHref : undefined}
|
||||
infoLink={x.href}
|
||||
/>
|
||||
)}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { News, NewsKind, NewsP, QueryIdentifier, getDisplayDate } from "@kyoo/models";
|
||||
import { News, NewsP, QueryIdentifier, getDisplayDate } from "@kyoo/models";
|
||||
import { ItemGrid } from "../browse/grid";
|
||||
import { InfiniteFetch } from "../fetch-infinite";
|
||||
import { useTranslation } from "react-i18next";
|
||||
@@ -37,13 +37,13 @@ export const NewsList = () => {
|
||||
query={NewsList.query()}
|
||||
layout={{ ...ItemGrid.layout, layout: "horizontal" }}
|
||||
getItemType={(x, i) =>
|
||||
x.kind === NewsKind.Movie || (x.isLoading && i % 2) ? "movie" : "episode"
|
||||
x.kind === "movie" || (x.isLoading && i % 2) ? "movie" : "episode"
|
||||
}
|
||||
getItemSize={(kind) => (kind === "episode" ? 2 : 1)}
|
||||
empty={t("home.none")}
|
||||
>
|
||||
{(x, i) =>
|
||||
x.kind === NewsKind.Movie || (x.isLoading && i % 2) ? (
|
||||
x.kind === "movie" || (x.isLoading && i % 2) ? (
|
||||
<ItemGrid
|
||||
isLoading={x.isLoading as any}
|
||||
href={x.href}
|
||||
@@ -58,9 +58,9 @@ export const NewsList = () => {
|
||||
<EpisodeBox
|
||||
isLoading={x.isLoading as any}
|
||||
slug={x.slug}
|
||||
showSlug={x.kind === NewsKind.Episode ? x.showId : null}
|
||||
showSlug={x.kind === "episode" ? x.showId : null}
|
||||
name={
|
||||
x.kind === NewsKind.Episode
|
||||
x.kind === "episode"
|
||||
? `${x.show!.name} ${episodeDisplayNumber(x)}`
|
||||
: undefined
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
|
||||
import {
|
||||
Genre,
|
||||
ItemKind,
|
||||
KyooImage,
|
||||
LibraryItem,
|
||||
LibraryItemP,
|
||||
@@ -258,24 +257,20 @@ export const Recommanded = () => {
|
||||
<ItemDetails
|
||||
isLoading={x.isLoading as any}
|
||||
slug={x.slug}
|
||||
type={x.kind?.toLowerCase() as any}
|
||||
type={x.kind}
|
||||
name={x.name}
|
||||
tagline={"tagline" in x ? x.tagline : null}
|
||||
overview={x.overview}
|
||||
poster={x.poster}
|
||||
subtitle={
|
||||
x.kind !== ItemKind.Collection && !x.isLoading ? getDisplayDate(x) : undefined
|
||||
}
|
||||
subtitle={x.kind !== "collection" && !x.isLoading ? getDisplayDate(x) : undefined}
|
||||
genres={"genres" in x ? x.genres : null}
|
||||
href={x.href}
|
||||
playHref={x.kind !== ItemKind.Collection && !x.isLoading ? x.playHref : undefined}
|
||||
playHref={x.kind !== "collection" && !x.isLoading ? x.playHref : undefined}
|
||||
watchStatus={
|
||||
!x.isLoading && x.kind !== ItemKind.Collection ? x.watchStatus?.status ?? null : null
|
||||
!x.isLoading && x.kind !== "collection" ? x.watchStatus?.status ?? null : null
|
||||
}
|
||||
unseenEpisodesCount={
|
||||
x.kind === ItemKind.Show
|
||||
? x.watchStatus?.unseenEpisodesCount ?? x.episodesCount!
|
||||
: null
|
||||
x.kind === "show" ? x.watchStatus?.unseenEpisodesCount ?? x.episodesCount! : null
|
||||
}
|
||||
/>
|
||||
)}
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
import {
|
||||
QueryIdentifier,
|
||||
Watchlist,
|
||||
WatchlistKind,
|
||||
WatchlistP,
|
||||
getDisplayDate,
|
||||
useAccount,
|
||||
@@ -48,7 +47,7 @@ export const WatchlistList = () => {
|
||||
query={WatchlistList.query()}
|
||||
layout={{ ...ItemGrid.layout, layout: "horizontal" }}
|
||||
getItemType={(x, i) =>
|
||||
(x.kind === WatchlistKind.Show && x.watchStatus?.nextEpisode) || (x.isLoading && i % 2)
|
||||
(x.kind === "show" && x.watchStatus?.nextEpisode) || (x.isLoading && i % 2)
|
||||
? "episode"
|
||||
: "item"
|
||||
}
|
||||
@@ -56,8 +55,8 @@ export const WatchlistList = () => {
|
||||
empty={t("home.none")}
|
||||
>
|
||||
{(x, i) => {
|
||||
const episode = x.kind === WatchlistKind.Show ? x.watchStatus?.nextEpisode : null;
|
||||
return (x.kind === WatchlistKind.Show && x.watchStatus?.nextEpisode) ||
|
||||
const episode = x.kind === "show" ? x.watchStatus?.nextEpisode : null;
|
||||
return (x.kind === "show" && x.watchStatus?.nextEpisode) ||
|
||||
(x.isLoading && i % 2) ? (
|
||||
<EpisodeBox
|
||||
isLoading={x.isLoading as any}
|
||||
@@ -83,9 +82,9 @@ export const WatchlistList = () => {
|
||||
watchStatus={x.watchStatus?.status || null}
|
||||
watchPercent={x.watchStatus?.watchedPercent || null}
|
||||
unseenEpisodesCount={
|
||||
x.kind === WatchlistKind.Show ? x.watchStatus?.unseenEpisodesCount : null
|
||||
x.kind === "show" ? x.watchStatus?.unseenEpisodesCount : null
|
||||
}
|
||||
type={x.kind === WatchlistKind.Movie ? "movie" : "show"}
|
||||
type={x.kind}
|
||||
/>
|
||||
);
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user