diff --git a/api/queries/functions/recents.ts b/api/queries/functions/recents.ts index 63095049..c7527b98 100644 --- a/api/queries/functions/recents.ts +++ b/api/queries/functions/recents.ts @@ -2,16 +2,24 @@ import { Api } from "@jellyfin/sdk/lib/api"; import { BaseItemDto, ItemSortBy } from "@jellyfin/sdk/lib/generated-client/models"; import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api"; -export function fetchRecentlyPlayed(api: Api): Promise { +export function fetchRecentlyPlayed(api: Api): Promise { + + console.debug("Fetching recently played items"); + return new Promise(async (resolve, reject) => { getItemsApi(api).getItems({ sortBy: [ ItemSortBy.DatePlayed ], limit: 100 }) .then((response) => { + console.debug("Received recently played items response"); + if (response.data.Items) resolve(response.data.Items); else { resolve([]); } + }).catch((error) => { + console.error(error); + reject(error); }) }) } \ No newline at end of file