lint and prettier

This commit is contained in:
2025-09-02 01:08:47 +02:00
parent dcace859a4
commit 63618d15f4
15 changed files with 28 additions and 32 deletions

View File

@@ -26,7 +26,7 @@ const Api = new V2({ baseUrl: apiUri });
const manga: Manga[] = []; const manga: Manga[] = [];
const promises: Map<string, Promise<Manga | undefined>> = new Map(); const promises: Map<string, Promise<Manga | undefined>> = new Map();
const getManga = async (key: string): Promise<Manga | undefined> => { const getManga = async (key: string): Promise<Manga | undefined> => {
let result = manga.find((m) => m.key === key); const result = manga.find((m) => m.key === key);
if (result) return result; if (result) return result;
if (promises.has(key)) return promises.get(key); if (promises.has(key)) return promises.get(key);
const newPromise = retrieveManga(key); const newPromise = retrieveManga(key);

View File

@@ -43,7 +43,7 @@ export default function MangaConnectorLink({
imageRef.current.setHTMLUnsafe( imageRef.current.setHTMLUnsafe(
`<img ref=${imageRef} src=${mangaConnector?.iconUrl} style=${imageStyle}/>`, `<img ref=${imageRef} src=${mangaConnector?.iconUrl} style=${imageStyle}/>`,
); );
}, []); }, [MangaConnectorId, imageStyle, mangaConnector, mangaConnectorContext]);
return ( return (
<Tooltip <Tooltip
@@ -96,7 +96,7 @@ export function MangaConnectorLinkFromId({
); );
}, },
); );
}, []); }, [Api, MangaConnectorIdId, imageStyle, printName]);
return node; return node;
} }

View File

@@ -36,10 +36,10 @@ export function MangaCard({
manga: MinimalManga | undefined; manga: MinimalManga | undefined;
children?: ReactNode; children?: ReactNode;
}) { }) {
if (manga === undefined) return PlaceHolderCard();
const [open, setOpen] = useState(false); const [open, setOpen] = useState(false);
if (manga === undefined) return PlaceHolderCard();
return ( return (
<MangaConnectorBadge manga={manga}> <MangaConnectorBadge manga={manga}>
<Card className={"manga-card"} onClick={() => setOpen(true)}> <Card className={"manga-card"} onClick={() => setOpen(true)}>
@@ -73,7 +73,7 @@ export function MangaModal({
const [manga, setManga] = useState<Manga>(); const [manga, setManga] = useState<Manga>();
useEffect(() => { useEffect(() => {
getManga(minimalManga.key).then(setManga); getManga(minimalManga.key).then(setManga);
}, []); }, [getManga, minimalManga]);
return ( return (
<Modal open={open} onClose={() => setOpen(false)} className={"manga-modal"}> <Modal open={open} onClose={() => setOpen(false)} className={"manga-modal"}>

View File

@@ -1,6 +1,6 @@
import { Badge } from "@mui/joy"; import { Badge } from "@mui/joy";
import { MinimalManga } from "../../apiClient/data-contracts.ts"; import { MinimalManga } from "../../apiClient/data-contracts.ts";
import { ReactElement } from "react"; import { ReactNode } from "react";
import "./MangaCard.css"; import "./MangaCard.css";
import MangaConnectorLink from "../MangaConnectorLink.tsx"; import MangaConnectorLink from "../MangaConnectorLink.tsx";
@@ -9,7 +9,7 @@ export default function MangaConnectorBadge({
children, children,
}: { }: {
manga: MinimalManga; manga: MinimalManga;
children?: ReactElement<any, any> | ReactElement<any, any>[] | undefined; children?: ReactNode;
}) { }) {
return ( return (
<Badge <Badge

View File

@@ -15,6 +15,7 @@ import Sheet from "@mui/joy/Sheet";
import { FileLibraryContext, MangaContext } from "../../App.tsx"; import { FileLibraryContext, MangaContext } from "../../App.tsx";
import { ApiContext } from "../../apiClient/ApiContext.tsx"; import { ApiContext } from "../../apiClient/ApiContext.tsx";
import { LoadingState, StateIndicator } from "../Loading.tsx"; import { LoadingState, StateIndicator } from "../Loading.tsx";
import * as React from "react";
export default function ({ mangaId }: { mangaId: string }): ReactNode { export default function ({ mangaId }: { mangaId: string }): ReactNode {
const [open, setOpen] = useState(false); const [open, setOpen] = useState(false);
@@ -22,7 +23,7 @@ export default function ({ mangaId }: { mangaId: string }): ReactNode {
const [manga, setManga] = useState<Manga>(); const [manga, setManga] = useState<Manga>();
useEffect(() => { useEffect(() => {
getManga(mangaId).then(setManga); getManga(mangaId).then(setManga);
}, []); }, [getManga, mangaId]);
return ( return (
<> <>
@@ -44,10 +45,13 @@ function DownloadDrawer({
const fileLibraries = useContext(FileLibraryContext); const fileLibraries = useContext(FileLibraryContext);
const Api = useContext(ApiContext); const Api = useContext(ApiContext);
const onLibraryChange = (_: any, value: {} | null) => { const onLibraryChange = (
_: React.MouseEvent | React.KeyboardEvent | React.FocusEvent | null,
value: string | null,
) => {
if (!value) return; if (!value) return;
if (!manga) return; if (!manga) return;
Api.mangaChangeLibraryCreate(manga.key as string, value as string); Api.mangaChangeLibraryCreate(manga.key, value);
}; };
return ( return (
@@ -97,7 +101,7 @@ function DownloadCheckBox({
} else setLoading(LoadingState.failure); } else setLoading(LoadingState.failure);
}) })
.catch((_) => setLoading(LoadingState.failure)); .catch((_) => setLoading(LoadingState.failure));
}, []); }, [Api, mangaConnectorIdId]);
const onSelected = (event: ChangeEvent<HTMLInputElement>) => { const onSelected = (event: ChangeEvent<HTMLInputElement>) => {
setLoading(LoadingState.loading); setLoading(LoadingState.loading);

View File

@@ -34,7 +34,7 @@ export default function ({
if (response.ok) setSimilar(response.data); if (response.ok) setSimilar(response.data);
}); });
}); });
}, [open]); }, [Api, manga, open]);
const exit = (manga: Manga) => { const exit = (manga: Manga) => {
setOpen(false); setOpen(false);

View File

@@ -103,7 +103,7 @@ function SearchDialog({
try { try {
new URL(url); new URL(url);
return true; return true;
} catch (Error) { } catch {
return false; return false;
} }
}; };

View File

@@ -10,14 +10,10 @@ export default function () {
>([]); >([]);
useEffect(() => { useEffect(() => {
getConnectors();
}, []);
const getConnectors = () => {
Api.libraryConnectorList().then((r) => { Api.libraryConnectorList().then((r) => {
if (r.ok) setLibraryConnectors(r.data); if (r.ok) setLibraryConnectors(r.data);
}); });
}; }, [Api]);
return ( return (
<Stack direction={"column"} spacing={1}> <Stack direction={"column"} spacing={1}>

View File

@@ -18,6 +18,7 @@ import {
PushoverRecord, PushoverRecord,
} from "../../../apiClient/data-contracts.ts"; } from "../../../apiClient/data-contracts.ts";
import { LoadingState, StateColor, StateIndicator } from "../../Loading.tsx"; import { LoadingState, StateColor, StateIndicator } from "../../Loading.tsx";
import * as React from "react";
export default function ({ export default function ({
open, open,
@@ -53,7 +54,7 @@ function NotificationConnectorTab({
}: { }: {
value: string; value: string;
children: ReactNode; children: ReactNode;
add: (data: any) => void; add: React.MouseEventHandler<HTMLAnchorElement> | undefined;
state: LoadingState; state: LoadingState;
}) { }) {
const IsLoading = (state: LoadingState): boolean => const IsLoading = (state: LoadingState): boolean =>

View File

@@ -18,14 +18,10 @@ export default function () {
>([]); >([]);
useEffect(() => { useEffect(() => {
getConnectors();
}, []);
const getConnectors = () => {
Api.notificationConnectorList().then((r) => { Api.notificationConnectorList().then((r) => {
if (r.ok) setNotificationConnectors(r.data); if (r.ok) setNotificationConnectors(r.data);
}); });
}; }, [Api]);
return ( return (
<Stack direction={"column"} spacing={1}> <Stack direction={"column"} spacing={1}>

View File

@@ -51,7 +51,7 @@ export default function Settings({
Api.settingsList().then((response) => { Api.settingsList().then((response) => {
setSettings(response.data); setSettings(response.data);
}); });
}, []); }, [Api]);
const apiUriChanged = (e: React.ChangeEvent<HTMLInputElement>) => { const apiUriChanged = (e: React.ChangeEvent<HTMLInputElement>) => {
clearTimeout(timerRef.current); clearTimeout(timerRef.current);

View File

@@ -17,7 +17,7 @@ export default function (): ReactNode {
setWorkers(response.data); setWorkers(response.data);
} }
}); });
}, []); }, [Api]);
return ( return (
<> <>

View File

@@ -1,6 +1,6 @@
import Sheet from "@mui/joy/Sheet"; import Sheet from "@mui/joy/Sheet";
import { Link, Stack, Typography } from "@mui/joy"; import { Link, Stack, Typography } from "@mui/joy";
import { ReactElement, useContext } from "react"; import { ReactElement, ReactNode, useContext } from "react";
import "./Header.css"; import "./Header.css";
import { Article, GitHub } from "@mui/icons-material"; import { Article, GitHub } from "@mui/icons-material";
import { ApiContext } from "./apiClient/ApiContext.tsx"; import { ApiContext } from "./apiClient/ApiContext.tsx";
@@ -8,7 +8,7 @@ import { ApiContext } from "./apiClient/ApiContext.tsx";
export default function Header({ export default function Header({
children, children,
}: { }: {
children?: ReactElement<any, any> | ReactElement<any, any>[] | undefined; children?: ReactNode;
}): ReactElement { }): ReactElement {
const Api = useContext(ApiContext); const Api = useContext(ApiContext);

View File

@@ -6,12 +6,11 @@ const [settingsPromise, setSettingsPromise] =
useState<Promise<TrangaSettings | undefined>>(); useState<Promise<TrangaSettings | undefined>>();
const [settings, setSettings] = useState<TrangaSettings>(); const [settings, setSettings] = useState<TrangaSettings>();
const API = useContext(ApiContext);
export const SettingsContext = createContext<{ export const SettingsContext = createContext<{
GetSettings: () => Promise<TrangaSettings | undefined>; GetSettings: () => Promise<TrangaSettings | undefined>;
}>({ }>({
GetSettings: (): Promise<TrangaSettings | undefined> => { GetSettings: (): Promise<TrangaSettings | undefined> => {
const API = useContext(ApiContext);
const promise = settingsPromise; const promise = settingsPromise;
if (promise) return promise; if (promise) return promise;
const p = new Promise<TrangaSettings | undefined>((resolve, reject) => { const p = new Promise<TrangaSettings | undefined>((resolve, reject) => {

View File

@@ -1,7 +1,7 @@
import { createRoot } from "react-dom/client"; import { createRoot } from "react-dom/client";
import "./index.css"; import "./index.css";
import App from "./App.tsx"; import App from "./App.tsx";
// @ts-ignore // @ts-expect-error font
import "@fontsource/inter"; import "@fontsource/inter";
import { CssVarsProvider } from "@mui/joy/styles"; import { CssVarsProvider } from "@mui/joy/styles";
import CssBaseline from "@mui/joy/CssBaseline"; import CssBaseline from "@mui/joy/CssBaseline";