mirror of
https://github.com/anultravioletaurora/Jellify.git
synced 2026-05-13 00:54:02 -05:00
fixing build?
This commit is contained in:
+3
-3
@@ -24,10 +24,10 @@ export const usePublicApi = (serverUrl: string) => useQuery({
|
||||
}
|
||||
})
|
||||
|
||||
export const useApi = (serverUrl: string) => useQuery({
|
||||
queryKey: [QueryKeys.Api, serverUrl],
|
||||
export const useApi = () => useQuery({
|
||||
queryKey: [QueryKeys.Api],
|
||||
queryFn: async ({ queryKey }) => {
|
||||
createApi(queryKey[1]);
|
||||
createApi();
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import { createApi } from "./functions/api";
|
||||
export const useArtistAlbums : (artistId: string) => UseQueryResult<BaseItemDto[], Error> = (artistId: string) => useQuery({
|
||||
queryKey: [QueryKeys.ArtistAlbums, artistId],
|
||||
queryFn: async ({ queryKey }) => {
|
||||
return getItemsApi(await createApi(await fetchServerUrl))
|
||||
return getItemsApi(await createApi())
|
||||
.getItems({ albumArtistIds: [queryKey[1]] })
|
||||
.then((result) => {
|
||||
return result.data.Items
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import { Api } from "@jellyfin/sdk";
|
||||
import { client } from "../../queries";
|
||||
import { fetchCredentials } from "./keychain";
|
||||
import { fetchCredentials } from "./storage";
|
||||
|
||||
|
||||
export const createApi: (serverUrl: string) => Promise<Api> = async (serverUrl) => {
|
||||
let credentials = await fetchCredentials(serverUrl)
|
||||
export const createApi: () => Promise<Api> = async () => {
|
||||
let credentials = await fetchCredentials()
|
||||
return client.createApi(credentials.server, credentials.password);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,29 @@
|
||||
import AsyncStorage from "@react-native-async-storage/async-storage"
|
||||
import { AsyncStorageKeys } from "../../../enums/async-storage-keys"
|
||||
import _ from "lodash";
|
||||
import * as Keychain from "react-native-keychain"
|
||||
|
||||
|
||||
export const fetchCredentials : () => Promise<Keychain.SharedWebCredentials> = () => new Promise(async (resolve, reject) => {
|
||||
|
||||
console.log("Attempting to use stored credentials");
|
||||
|
||||
let serverUrl = await AsyncStorage.getItem(AsyncStorageKeys.ServerUrl);
|
||||
|
||||
console.debug(`REMOVE THIS::Server Url ${serverUrl}`);
|
||||
|
||||
if (!_.isNull(serverUrl))
|
||||
Keychain.getInternetCredentials(serverUrl!)
|
||||
.then((keychain) => {
|
||||
if (!keychain)
|
||||
reject(new Error("Unable to retrieve credentials for server address"))
|
||||
|
||||
resolve(keychain as Keychain.SharedWebCredentials)
|
||||
})
|
||||
|
||||
reject(new Error("Unable to retrieve credentials without a server URL"));
|
||||
});
|
||||
|
||||
export const fetchServerUrl : Promise<string> = new Promise(async (resolve, reject) => {
|
||||
|
||||
console.log("Attempting to fetch server address from storage");
|
||||
|
||||
+2
-17
@@ -1,24 +1,9 @@
|
||||
import { useQuery } from "@tanstack/react-query"
|
||||
import { QueryKeys } from "../../enums/query-keys"
|
||||
import { fetchServerUrl } from "./functions/storage";
|
||||
import _ from "lodash";
|
||||
import * as Keychain from "react-native-keychain"
|
||||
import AsyncStorage from "@react-native-async-storage/async-storage";
|
||||
import { AsyncStorageKeys } from "../../enums/async-storage-keys";
|
||||
import { fetchCredentials } from "./functions/storage";
|
||||
|
||||
export const useCredentials = useQuery({
|
||||
queryKey: [QueryKeys.Credentials],
|
||||
queryFn: async () => {
|
||||
|
||||
console.log("Attempting to use stored credentials");
|
||||
|
||||
let serverUrl = await AsyncStorage.getItem(AsyncStorageKeys.ServerUrl);
|
||||
|
||||
console.debug(`REMOVE THIS::Server Url ${serverUrl}`);
|
||||
|
||||
if (!_.isNull(serverUrl))
|
||||
return Keychain.getInternetCredentials(serverUrl!);
|
||||
|
||||
return new Error("Unable to retrieve credentials without a server URL")
|
||||
}
|
||||
queryFn: fetchCredentials
|
||||
});
|
||||
@@ -2,12 +2,11 @@ import { useQuery } from "@tanstack/react-query";
|
||||
import { QueryKeys } from "../../enums/query-keys";
|
||||
import { getPlaylistsApi } from "@jellyfin/sdk/lib/utils/api/playlists-api"
|
||||
import { createApi } from "./functions/api";
|
||||
import { fetchServerUrl } from "./functions/storage";
|
||||
|
||||
|
||||
export const usePlaylists = useQuery({
|
||||
queryKey: [QueryKeys.Playlists],
|
||||
queryFn: async () => {
|
||||
return getPlaylistsApi(await createApi(await fetchServerUrl))
|
||||
return getPlaylistsApi(await createApi())
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user