Use different caches for differents servers

This commit is contained in:
Zoe Roux 2023-07-17 00:36:00 +09:00
parent 1e55b7bf50
commit 4c84f857e7

View File

@ -32,7 +32,6 @@ import { KyooErrors } from "./kyoo-errors";
import { Page, Paged } from "./page"; import { Page, Paged } from "./page";
import { Platform } from "react-native"; import { Platform } from "react-native";
import { getToken } from "./login"; import { getToken } from "./login";
import { getSecureItem } from "./secure-store";
const kyooUrl = const kyooUrl =
Platform.OS !== "web" Platform.OS !== "web"
@ -73,7 +72,7 @@ export const queryFn = async <Data,>(
? context.path.filter((x) => x) ? context.path.filter((x) => x)
: context.pageParam : context.pageParam
? [context.pageParam] ? [context.pageParam]
: (context.queryKey.filter((x) => x) as string[]), : (context.queryKey.filter((x, i) => x && i) as string[]),
) )
.join("/") .join("/")
.replace("/?", "?"); .replace("/?", "?");
@ -161,6 +160,7 @@ export type QueryPage<Props = {}> = ComponentType<Props> & {
const toQueryKey = <Data,>(query: QueryIdentifier<Data>) => { const toQueryKey = <Data,>(query: QueryIdentifier<Data>) => {
if (query.params) { if (query.params) {
return [ return [
kyooApiUrl,
...query.path, ...query.path,
"?" + "?" +
Object.entries(query.params) Object.entries(query.params)
@ -169,7 +169,7 @@ const toQueryKey = <Data,>(query: QueryIdentifier<Data>) => {
.join("&"), .join("&"),
]; ];
} else { } else {
return query.path; return [kyooApiUrl, ...query.path];
} }
}; };