feat: Adding custom endpoint option for sections (#1118)

Co-authored-by: lostb1t <coding-mosses0z@icloud.com>
This commit is contained in:
Zach Ross-Clyne
2025-10-09 00:41:59 +01:00
committed by GitHub
parent 8c68283c56
commit f7e0667416
2 changed files with 19 additions and 0 deletions

View File

@@ -2,6 +2,7 @@ import { Feather, Ionicons } from "@expo/vector-icons";
import type { Api } from "@jellyfin/sdk";
import type {
BaseItemDto,
BaseItemDtoQueryResult,
BaseItemKind,
} from "@jellyfin/sdk/lib/generated-client/models";
import {
@@ -356,6 +357,16 @@ export const HomeIndex = () => {
});
return response.data || [];
}
if (section.custom) {
const response = await api.get<BaseItemDtoQueryResult>(
section.custom.endpoint,
{
params: { ...(section.custom.query || {}), userId: user?.Id },
headers: section.custom.headers || {},
},
);
return response.data.Items || [];
}
return [];
},
type: "ScrollingCollectionList",

View File

@@ -93,6 +93,7 @@ export type HomeSection = {
items?: HomeSectionItemResolver;
nextUp?: HomeSectionNextUpResolver;
latest?: HomeSectionLatestResolver;
custom?: HomeSectionCustomEndpointResolver;
};
export type HomeSectionItemResolver = {
@@ -106,6 +107,13 @@ export type HomeSectionItemResolver = {
filters?: Array<ItemFilter>;
};
export type HomeSectionCustomEndpointResolver = {
title?: string;
endpoint: string;
headers?: any;
query?: any;
};
export type HomeSectionNextUpResolver = {
parentId?: string;
limit?: number;