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