mirror of
https://github.com/Jellify-Music/App.git
synced 2026-04-26 04:49:27 -05:00
So does this still work? Maybe even work better?
This commit is contained in:
@@ -1,20 +1,20 @@
|
||||
import { Api } from "@jellyfin/sdk/lib/api";
|
||||
import { BaseItemDto, BaseItemKind, ItemSortBy, SortOrder } from "@jellyfin/sdk/lib/generated-client/models";
|
||||
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
||||
import { queryConfig } from "../query.config";
|
||||
import Client from "@/api/client";
|
||||
|
||||
export function fetchRecentlyPlayed(api: Api, libraryId: string): Promise<BaseItemDto[]> {
|
||||
export function fetchRecentlyPlayed(): Promise<BaseItemDto[]> {
|
||||
|
||||
console.debug("Fetching recently played items", api);
|
||||
console.debug("Fetching recently played items");
|
||||
|
||||
return new Promise(async (resolve, reject) => {
|
||||
getItemsApi(api)
|
||||
getItemsApi(Client.instance.api!)
|
||||
.getItems({
|
||||
includeItemTypes: [
|
||||
BaseItemKind.Audio
|
||||
],
|
||||
limit: queryConfig.limits.recents,
|
||||
parentId: libraryId,
|
||||
parentId: Client.instance.library!.musicLibraryId,
|
||||
recursive: true,
|
||||
sortBy: [
|
||||
ItemSortBy.DatePlayed
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
import { Api } from "@jellyfin/sdk";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { QueryKeys } from "../../enums/query-keys";
|
||||
import { fetchRecentlyPlayed } from "./functions/recents";
|
||||
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api"
|
||||
import Client from "../client";
|
||||
|
||||
export const useRecentlyPlayed = (api: Api, libraryId: string) => useQuery({
|
||||
queryKey: [QueryKeys.RecentlyPlayed, api, libraryId],
|
||||
queryFn: ({ queryKey }) => {
|
||||
export const useRecentlyPlayed = useQuery({
|
||||
queryKey: [QueryKeys.RecentlyPlayed],
|
||||
queryFn: () => {
|
||||
|
||||
return fetchRecentlyPlayed(api, libraryId)
|
||||
return fetchRecentlyPlayed()
|
||||
}
|
||||
});
|
||||
|
||||
export const useRecentlyPlayedArtists = (api: Api, libraryId: string) => useQuery({
|
||||
queryKey: [QueryKeys.RecentlyPlayedArtists, api, libraryId],
|
||||
queryFn: ({ queryKey }) => {
|
||||
return fetchRecentlyPlayed(queryKey[1] as Api, queryKey[2] as string)
|
||||
export const useRecentlyPlayedArtists = useQuery({
|
||||
queryKey: [QueryKeys.RecentlyPlayedArtists],
|
||||
queryFn: () => {
|
||||
return fetchRecentlyPlayed()
|
||||
.then((tracks) => {
|
||||
return getItemsApi(api)
|
||||
return getItemsApi(Client.instance.api!)
|
||||
.getItems({
|
||||
ids: tracks.map(track => track.ArtistItems![0].Id!)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user