mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-07 20:40:15 +02:00
include transcode settings and server features in api context
This commit is contained in:
@@ -67,13 +67,28 @@ const getPathReplaceSettings = () => {
|
||||
return { pathReplace, pathReplaceWith };
|
||||
};
|
||||
|
||||
const getTranscodeSettings = () => {
|
||||
const transcode = useSettingsStore.getState().playback.transcode;
|
||||
return transcode;
|
||||
};
|
||||
|
||||
const getServerFeatures = () => {
|
||||
const serverFeatures = useAuthStore.getState().currentServer?.features;
|
||||
return serverFeatures;
|
||||
};
|
||||
|
||||
const addContext = <T extends { apiClientProps: any; context?: any }>(args: T): T => {
|
||||
const pathSettings = getPathReplaceSettings();
|
||||
const transcodeSettings = getTranscodeSettings();
|
||||
const serverFeatures = getServerFeatures();
|
||||
|
||||
return {
|
||||
...args,
|
||||
context: {
|
||||
...(args.context || {}),
|
||||
...pathSettings,
|
||||
serverFeatures: serverFeatures,
|
||||
transcode: transcodeSettings,
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
@@ -410,16 +410,24 @@ export type Song = {
|
||||
userRating: null | number;
|
||||
};
|
||||
|
||||
type ApiContext = {
|
||||
pathReplace?: string;
|
||||
pathReplaceWith?: string;
|
||||
serverFeatures?: ServerFeatures;
|
||||
transcode?: {
|
||||
bitrate?: number;
|
||||
enabled?: boolean;
|
||||
format?: string[];
|
||||
};
|
||||
};
|
||||
|
||||
type BaseEndpointArgs = {
|
||||
apiClientProps: {
|
||||
server?: null | ServerListItemWithCredential;
|
||||
serverId: string;
|
||||
signal?: AbortSignal;
|
||||
};
|
||||
context?: {
|
||||
pathReplace?: string;
|
||||
pathReplaceWith?: string;
|
||||
};
|
||||
context?: ApiContext;
|
||||
};
|
||||
|
||||
type GenreListSortMap = {
|
||||
@@ -1563,7 +1571,7 @@ export type InternalControllerEndpoint = {
|
||||
getSongDetail: (args: ReplaceApiClientProps<SongDetailArgs>) => Promise<SongDetailResponse>;
|
||||
getSongList: (args: ReplaceApiClientProps<SongListArgs>) => Promise<SongListResponse>;
|
||||
getSongListCount: (args: ReplaceApiClientProps<SongListCountArgs>) => Promise<number>;
|
||||
getStreamUrl: (args: ReplaceApiClientProps<StreamArgs>) => string;
|
||||
getStreamUrl: (args: ReplaceApiClientProps<StreamArgs>) => Promise<string>;
|
||||
getStructuredLyrics?: (
|
||||
args: ReplaceApiClientProps<StructuredLyricsArgs>,
|
||||
) => Promise<StructuredLyric[]>;
|
||||
@@ -1673,7 +1681,6 @@ export type StreamQuery = {
|
||||
mediaType?: 'podcast' | 'song';
|
||||
offset?: number;
|
||||
transcode: boolean;
|
||||
transcodeParams?: string;
|
||||
};
|
||||
|
||||
export type StructuredLyric = (StructuredSyncedLyric | StructuredUnsyncedLyric) & {
|
||||
@@ -1780,8 +1787,5 @@ type BaseEndpointArgsWithServer = {
|
||||
serverId: string;
|
||||
signal?: AbortSignal;
|
||||
};
|
||||
context?: {
|
||||
pathReplace?: string;
|
||||
pathReplaceWith?: string;
|
||||
};
|
||||
context?: ApiContext;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user