mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
Format code
This commit is contained in:
parent
883f39e4b5
commit
14540081be
@ -38,13 +38,15 @@ export const TokenP = z.object({
|
||||
});
|
||||
export type Token = z.infer<typeof TokenP>;
|
||||
|
||||
export const AccountP = UserP.merge(z.object({
|
||||
// set it optional for accounts logged in before the kind was present
|
||||
kind: z.literal("user").optional(),
|
||||
token: TokenP,
|
||||
apiUrl: z.string(),
|
||||
selected: z.boolean(),
|
||||
}));
|
||||
export const AccountP = UserP.merge(
|
||||
z.object({
|
||||
// set it optional for accounts logged in before the kind was present
|
||||
kind: z.literal("user").optional(),
|
||||
token: TokenP,
|
||||
apiUrl: z.string(),
|
||||
selected: z.boolean(),
|
||||
}),
|
||||
);
|
||||
export type Account = z.infer<typeof AccountP>;
|
||||
|
||||
const AccountContext = createContext<(Account & { select: () => void; remove: () => void })[]>([]);
|
||||
|
@ -40,7 +40,7 @@ export let kyooApiUrl = kyooUrl;
|
||||
|
||||
export const queryFn = async <Data,>(
|
||||
context:
|
||||
| (QueryFunctionContext & { timeout?: number, apiUrl?: string })
|
||||
| (QueryFunctionContext & { timeout?: number; apiUrl?: string })
|
||||
| {
|
||||
path: (string | false | undefined | null)[];
|
||||
body?: object;
|
||||
|
@ -31,7 +31,7 @@ export const CollectionP = withImages(
|
||||
* The summary of this show.
|
||||
*/
|
||||
overview: z.string().nullable(),
|
||||
})
|
||||
}),
|
||||
).transform((x) => ({
|
||||
...x,
|
||||
href: `/collection/${x.slug}`,
|
||||
|
@ -52,12 +52,9 @@ export const itemMap = (
|
||||
thumbnail: item.thumbnail,
|
||||
watchStatus: item.kind !== "collection" ? item.watchStatus?.status ?? null : null,
|
||||
type: item.kind,
|
||||
watchPercent:
|
||||
item.kind !== "collection" ? item.watchStatus?.watchedPercent ?? null : null,
|
||||
watchPercent: item.kind !== "collection" ? item.watchStatus?.watchedPercent ?? null : null,
|
||||
unseenEpisodesCount:
|
||||
item.kind === "show"
|
||||
? item.watchStatus?.unseenEpisodesCount ?? item.episodesCount!
|
||||
: null,
|
||||
item.kind === "show" ? item.watchStatus?.unseenEpisodesCount ?? item.episodesCount! : null,
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -36,9 +36,7 @@ export const NewsList = () => {
|
||||
<InfiniteFetch
|
||||
query={NewsList.query()}
|
||||
layout={{ ...ItemGrid.layout, layout: "horizontal" }}
|
||||
getItemType={(x, i) =>
|
||||
x.kind === "movie" || (x.isLoading && i % 2) ? "movie" : "episode"
|
||||
}
|
||||
getItemType={(x, i) => (x.kind === "movie" || (x.isLoading && i % 2) ? "movie" : "episode")}
|
||||
getItemSize={(kind) => (kind === "episode" ? 2 : 1)}
|
||||
empty={t("home.none")}
|
||||
>
|
||||
@ -59,11 +57,7 @@ export const NewsList = () => {
|
||||
isLoading={x.isLoading as any}
|
||||
slug={x.slug}
|
||||
showSlug={x.kind === "episode" ? x.showId : null}
|
||||
name={
|
||||
x.kind === "episode"
|
||||
? `${x.show!.name} ${episodeDisplayNumber(x)}`
|
||||
: undefined
|
||||
}
|
||||
name={x.kind === "episode" ? `${x.show!.name} ${episodeDisplayNumber(x)}` : undefined}
|
||||
overview={x.name}
|
||||
thumbnail={x.thumbnail}
|
||||
href={x.href}
|
||||
|
@ -18,13 +18,7 @@
|
||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {
|
||||
QueryIdentifier,
|
||||
Watchlist,
|
||||
WatchlistP,
|
||||
getDisplayDate,
|
||||
useAccount,
|
||||
} from "@kyoo/models";
|
||||
import { QueryIdentifier, Watchlist, WatchlistP, getDisplayDate, useAccount } from "@kyoo/models";
|
||||
import { useYoshiki } from "yoshiki/native";
|
||||
import { ItemGrid } from "../browse/grid";
|
||||
import { InfiniteFetch } from "../fetch-infinite";
|
||||
@ -56,8 +50,7 @@ export const WatchlistList = () => {
|
||||
>
|
||||
{(x, i) => {
|
||||
const episode = x.kind === "show" ? x.watchStatus?.nextEpisode : null;
|
||||
return (x.kind === "show" && x.watchStatus?.nextEpisode) ||
|
||||
(x.isLoading && i % 2) ? (
|
||||
return (x.kind === "show" && x.watchStatus?.nextEpisode) || (x.isLoading && i % 2) ? (
|
||||
<EpisodeBox
|
||||
isLoading={x.isLoading as any}
|
||||
slug={episode?.slug}
|
||||
@ -81,9 +74,7 @@ export const WatchlistList = () => {
|
||||
poster={x.poster}
|
||||
watchStatus={x.watchStatus?.status || null}
|
||||
watchPercent={x.watchStatus?.watchedPercent || null}
|
||||
unseenEpisodesCount={
|
||||
x.kind === "show" ? x.watchStatus?.unseenEpisodesCount : null
|
||||
}
|
||||
unseenEpisodesCount={x.kind === "show" ? x.watchStatus?.unseenEpisodesCount : null}
|
||||
type={x.kind}
|
||||
/>
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user