From 12fdff877f5c36a797560a7523d53a72b5fc5680 Mon Sep 17 00:00:00 2001 From: Violet Caulfield Date: Sat, 23 Nov 2024 07:47:14 -0600 Subject: [PATCH] trying to navigate to the home screen now that the library is stored --- components/Login/helpers/server-library.tsx | 13 +++++-------- components/jellyfin-api-provider.tsx | 1 + types/JellifyLibrary.ts | 6 +++--- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/components/Login/helpers/server-library.tsx b/components/Login/helpers/server-library.tsx index 186d53af..e2dd858a 100644 --- a/components/Login/helpers/server-library.tsx +++ b/components/Login/helpers/server-library.tsx @@ -16,10 +16,7 @@ import { BaseItemDto } from "@jellyfin/sdk/lib/generated-client/models"; export default function ServerLibrary(): React.JSX.Element { - const [musicLibrary, setMusicLibrary] = useState(undefined); - - const { libraryName, setLibraryName, libraryId, setLibraryId } = useAuthenticationContext(); - + const { libraryId, setLibraryId } = useAuthenticationContext(); const { apiClient, setAccessToken, setLibrary } = useApiClientContext(); const useMusicLibraries = (api: Api) => useQuery({ @@ -33,7 +30,7 @@ export default function ServerLibrary(): React.JSX.Element { }) const { data : libraries, isError, isPending, refetch: refetchMusicLibraries } = useMusicLibraries(apiClient!); - const { data : playlistLibrary, isError: playlistLibraryError, refetch: refetchPlaylistLibrary } = usePlaylistLibrary(apiClient!); + const { data : playlistLibrary, refetch: refetchPlaylistLibrary } = usePlaylistLibrary(apiClient!); useEffect(() => { refetchMusicLibraries(); @@ -81,9 +78,9 @@ export default function ServerLibrary(): React.JSX.Element { setLibrary({ musicLibraryId: libraryId!, musicLibraryName: libraries?.filter((library) => library.Id == libraryId)[0].Name ?? "No library name", - musicLibraryImageId: libraries?.filter((library) => library.Id == libraryId)[0].ImageTags?.Primary ?? "", - playlistLibraryId: playlistLibrary?.Id ?? "", - playlistLibraryImageId: playlistLibrary?.ImageTags?.Primary ?? "", + musicLibraryPrimaryImageId: libraries?.filter((library) => library.Id == libraryId)[0].ImageTags!.Primary, + playlistLibraryId: playlistLibrary!.Id!, + playlistLibraryPrimaryImageId: playlistLibrary!.ImageTags!.Primary, }) }}> diff --git a/components/jellyfin-api-provider.tsx b/components/jellyfin-api-provider.tsx index e2c3ac44..850c7b3c 100644 --- a/components/jellyfin-api-provider.tsx +++ b/components/jellyfin-api-provider.tsx @@ -67,6 +67,7 @@ const JellyfinApiClientContextInitializer = () => { ]) useEffect(() => { + console.debug("Library changed") if (library) storage.set(MMKVStorageKeys.Library, JSON.stringify(library)); else diff --git a/types/JellifyLibrary.ts b/types/JellifyLibrary.ts index 7150f9b1..c25ca4f2 100644 --- a/types/JellifyLibrary.ts +++ b/types/JellifyLibrary.ts @@ -1,8 +1,8 @@ export interface JellifyLibrary { musicLibraryId: string; - musicLibraryName: string; - musicLibraryImageId: string; + musicLibraryName?: string; + musicLibraryPrimaryImageId?: string; playlistLibraryId: string; - playlistLibraryImageId: string; + playlistLibraryPrimaryImageId?: string; } \ No newline at end of file