mirror of
https://github.com/streamyfin/streamyfin.git
synced 2025-08-20 18:37:18 +02:00
possible suggested episodes bandaid
This commit is contained in:
@@ -245,15 +245,22 @@ export default function index() {
|
||||
{
|
||||
title: "Suggested Episodes",
|
||||
queryKey: ["suggestedEpisodes", user?.Id],
|
||||
queryFn: async () =>
|
||||
(
|
||||
await getSuggestionsApi(api).getSuggestions({
|
||||
userId: user?.Id,
|
||||
limit: 10,
|
||||
mediaType: ["Video"],
|
||||
type: ["Episode"],
|
||||
})
|
||||
).data.Items || [],
|
||||
queryFn: async () =>{
|
||||
try {
|
||||
const userId = user?.Id;
|
||||
if (!userId) return [];
|
||||
|
||||
const suggestions = await getSuggestions(api, userId);
|
||||
const nextUpPromises = suggestions.map(series => getNextUp(api, userId, series.Id!));
|
||||
const nextUpResults = await Promise.all(nextUpPromises);
|
||||
|
||||
return nextUpResults.filter(item => item !== null);
|
||||
} catch (error) {
|
||||
console.error('Error fetching data:', error);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
,
|
||||
type: "ScrollingCollectionList",
|
||||
orientation: "horizontal",
|
||||
},
|
||||
@@ -371,3 +378,23 @@ export default function index() {
|
||||
</ScrollView>
|
||||
);
|
||||
}
|
||||
|
||||
// Function to get suggestions
|
||||
async function getSuggestions(api: any, userId: string) {
|
||||
const response = await getSuggestionsApi(api).getSuggestions({
|
||||
userId,
|
||||
limit: 10,
|
||||
mediaType: ["Unknown"],
|
||||
type: ["Series"],
|
||||
});
|
||||
return response.data.Items ?? [];
|
||||
}
|
||||
|
||||
// Function to get the next up TV show for a series
|
||||
async function getNextUp(api: any, userId: string, seriesId: string) {
|
||||
const response = await getTvShowsApi(api).getNextUp({
|
||||
userId,
|
||||
seriesId,
|
||||
});
|
||||
return response.data.Items?.[0] ?? null;
|
||||
}
|
||||
Reference in New Issue
Block a user