mirror of
https://github.com/anultravioletaurora/Jellify.git
synced 2026-02-12 00:58:33 -06:00
32 lines
945 B
TypeScript
32 lines
945 B
TypeScript
import { Jellyfin } from "@jellyfin/sdk"
|
|
import { useQuery } from "@tanstack/react-query";
|
|
import { getDeviceNameSync, getUniqueIdSync } from "react-native-device-info"
|
|
import { QueryKeys } from "../enums/query-keys";
|
|
import { useCredentials } from "./queries/keychain";
|
|
import { name, version } from "../package.json"
|
|
|
|
export const client : Jellyfin = new Jellyfin({
|
|
clientInfo: {
|
|
name: name,
|
|
version: version
|
|
},
|
|
deviceInfo: {
|
|
name: getDeviceNameSync(),
|
|
id: getUniqueIdSync()
|
|
}
|
|
});
|
|
|
|
export const usePublicApi = (serverUrl: string) => useQuery({
|
|
queryKey: [QueryKeys.PublicApi, serverUrl],
|
|
queryFn: ({ queryKey }) => {
|
|
return client.createApi(serverUrl);
|
|
}
|
|
})
|
|
|
|
export const useApi = useQuery({
|
|
queryKey: [QueryKeys.Api],
|
|
queryFn: () => {
|
|
let credentials = useCredentials.data!
|
|
return client.createApi(credentials.server, credentials.password);
|
|
}
|
|
}) |