mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-01-15 15:48:05 +00:00
feat: Adding custom endpoint option for sections (#1118)
Co-authored-by: lostb1t <coding-mosses0z@icloud.com>
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user