adding some logging

This commit is contained in:
Violet Caulfield
2024-11-24 06:12:26 -06:00
parent fc9fcd7db3
commit 899f742037

View File

@@ -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<BaseItemDto[] | undefined> {
export function fetchRecentlyPlayed(api: Api): Promise<BaseItemDto[]> {
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);
})
})
}