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