mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
Fix types
This commit is contained in:
parent
93608c9549
commit
e3908da7a9
@ -41,6 +41,8 @@ export const login = async (
|
||||
timeout?: number,
|
||||
): Promise<Result<Account, string>> => {
|
||||
try {
|
||||
const controller = new AbortController();
|
||||
setTimeout(() => controller.abort(), 5_000);
|
||||
const token = await queryFn(
|
||||
{
|
||||
path: ["auth", action],
|
||||
@ -48,7 +50,7 @@ export const login = async (
|
||||
body,
|
||||
authenticated: false,
|
||||
apiUrl,
|
||||
timeout,
|
||||
signal: controller.signal,
|
||||
},
|
||||
TokenP,
|
||||
);
|
||||
|
@ -38,7 +38,7 @@ const kyooUrl =
|
||||
// The url of kyoo, set after each query (used by the image parser).
|
||||
export let kyooApiUrl = kyooUrl;
|
||||
|
||||
export const queryFn = async <Data,>(
|
||||
export const queryFn = async <Parser extends z.ZodTypeAny>(
|
||||
context: {
|
||||
apiUrl?: string;
|
||||
authenticated?: boolean;
|
||||
@ -51,9 +51,9 @@ export const queryFn = async <Data,>(
|
||||
plainText?: boolean;
|
||||
} & Partial<QueryFunctionContext>)
|
||||
),
|
||||
type?: z.ZodType<Data>,
|
||||
type?: Parser,
|
||||
token?: string | null,
|
||||
): Promise<Data> => {
|
||||
): Promise<z.infer<Parser>> => {
|
||||
const url = context.apiUrl ?? (Platform.OS === "web" ? kyooUrl : getCurrentAccount()!.apiUrl);
|
||||
kyooApiUrl = url;
|
||||
|
||||
@ -106,10 +106,9 @@ export const queryFn = async <Data,>(
|
||||
throw data as KyooErrors;
|
||||
}
|
||||
|
||||
// @ts-expect-error Assume Data is nullable.
|
||||
if (resp.status === 204) return null;
|
||||
|
||||
if ("plainText" in context && context.plainText) return (await resp.text()) as unknown as Data;
|
||||
if ("plainText" in context && context.plainText) return (await resp.text()) as unknown;
|
||||
|
||||
let data;
|
||||
try {
|
||||
|
@ -170,6 +170,7 @@ export const QualitiesMenu = (props: CustomMenu) => {
|
||||
}}
|
||||
/>
|
||||
{/* TODO: Support video tracks when the play mode is not hls. */}
|
||||
{/* @ts-expect-error They forgot to type this. */}
|
||||
{info?.videoTracks.map((x) => (
|
||||
<Menu.Item
|
||||
key={x.height}
|
||||
|
Loading…
x
Reference in New Issue
Block a user