diff --git a/components/CarPlay/Home.tsx b/components/CarPlay/Home.tsx index ed286740..b552823f 100644 --- a/components/CarPlay/Home.tsx +++ b/components/CarPlay/Home.tsx @@ -4,7 +4,8 @@ import { fetchRecentlyPlayed, fetchRecentlyPlayedArtists } from "../../api/queri import { CarPlay, ListTemplate } from "react-native-carplay"; import { CarPlayRecentlyPlayed } from "./RecentlyPlayed"; import { CarPlayRecentArtists } from "./RecentArtists"; -import { queryClient } from "@/constants/query-client"; +import { queryClient } from "../../constants/query-client"; +import { BaseItemDto } from "@jellyfin/sdk/lib/generated-client/models"; const CarPlayHome : ListTemplate = new ListTemplate({ id: 'Home', @@ -24,7 +25,7 @@ const CarPlayHome : ListTemplate = new ListTemplate({ switch (index) { case 0: - const artists = await fetchRecentlyPlayedArtists(); + const artists = queryClient.getQueryData([QueryKeys.RecentlyPlayedArtists]); CarPlay.pushTemplate(CarPlayRecentArtists(artists)) break; case 1: diff --git a/components/CarPlay/RecentArtists.tsx b/components/CarPlay/RecentArtists.tsx index 42b88c8a..6609da28 100644 --- a/components/CarPlay/RecentArtists.tsx +++ b/components/CarPlay/RecentArtists.tsx @@ -3,11 +3,11 @@ import { BaseItemDto, ImageType } from "@jellyfin/sdk/lib/generated-client/model import { ListTemplate } from "react-native-carplay" import { QueryKeys } from "../../enums/query-keys" -export const CarPlayRecentArtists = (artists : BaseItemDto[]) => new ListTemplate({ +export const CarPlayRecentArtists = (artists : BaseItemDto[] | undefined) => new ListTemplate({ title: "Recently Played", sections: [ { - items: artists.map(artist => { + items: artists ? artists.map(artist => { return { id: artist.Id!, text: artist.Name ? artist.Name : "Untitled Track", @@ -15,7 +15,7 @@ export const CarPlayRecentArtists = (artists : BaseItemDto[]) => new ListTemplat uri: queryClient.getQueryData([ QueryKeys.ItemImage, ImageType.Primary ]) } } - }) + }) : [] } ] }) \ No newline at end of file