mirror of
https://github.com/Jellify-Music/App.git
synced 2026-01-23 11:39:50 -06:00
recent artists from query data
This commit is contained in:
@@ -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<BaseItemDto[]>([QueryKeys.RecentlyPlayedArtists]);
|
||||
CarPlay.pushTemplate(CarPlayRecentArtists(artists))
|
||||
break;
|
||||
case 1:
|
||||
|
||||
@@ -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 ])
|
||||
}
|
||||
}
|
||||
})
|
||||
}) : []
|
||||
}
|
||||
]
|
||||
})
|
||||
Reference in New Issue
Block a user