include transcode settings and server features in api context

This commit is contained in:
jeffvli
2026-03-31 01:20:25 -07:00
parent 27c42dd9f4
commit ae2ce0866e
2 changed files with 29 additions and 10 deletions
+15
View File
@@ -67,13 +67,28 @@ const getPathReplaceSettings = () => {
return { pathReplace, pathReplaceWith }; 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 addContext = <T extends { apiClientProps: any; context?: any }>(args: T): T => {
const pathSettings = getPathReplaceSettings(); const pathSettings = getPathReplaceSettings();
const transcodeSettings = getTranscodeSettings();
const serverFeatures = getServerFeatures();
return { return {
...args, ...args,
context: { context: {
...(args.context || {}), ...(args.context || {}),
...pathSettings, ...pathSettings,
serverFeatures: serverFeatures,
transcode: transcodeSettings,
}, },
}; };
}; };
+14 -10
View File
@@ -410,16 +410,24 @@ export type Song = {
userRating: null | number; userRating: null | number;
}; };
type ApiContext = {
pathReplace?: string;
pathReplaceWith?: string;
serverFeatures?: ServerFeatures;
transcode?: {
bitrate?: number;
enabled?: boolean;
format?: string[];
};
};
type BaseEndpointArgs = { type BaseEndpointArgs = {
apiClientProps: { apiClientProps: {
server?: null | ServerListItemWithCredential; server?: null | ServerListItemWithCredential;
serverId: string; serverId: string;
signal?: AbortSignal; signal?: AbortSignal;
}; };
context?: { context?: ApiContext;
pathReplace?: string;
pathReplaceWith?: string;
};
}; };
type GenreListSortMap = { type GenreListSortMap = {
@@ -1563,7 +1571,7 @@ export type InternalControllerEndpoint = {
getSongDetail: (args: ReplaceApiClientProps<SongDetailArgs>) => Promise<SongDetailResponse>; getSongDetail: (args: ReplaceApiClientProps<SongDetailArgs>) => Promise<SongDetailResponse>;
getSongList: (args: ReplaceApiClientProps<SongListArgs>) => Promise<SongListResponse>; getSongList: (args: ReplaceApiClientProps<SongListArgs>) => Promise<SongListResponse>;
getSongListCount: (args: ReplaceApiClientProps<SongListCountArgs>) => Promise<number>; getSongListCount: (args: ReplaceApiClientProps<SongListCountArgs>) => Promise<number>;
getStreamUrl: (args: ReplaceApiClientProps<StreamArgs>) => string; getStreamUrl: (args: ReplaceApiClientProps<StreamArgs>) => Promise<string>;
getStructuredLyrics?: ( getStructuredLyrics?: (
args: ReplaceApiClientProps<StructuredLyricsArgs>, args: ReplaceApiClientProps<StructuredLyricsArgs>,
) => Promise<StructuredLyric[]>; ) => Promise<StructuredLyric[]>;
@@ -1673,7 +1681,6 @@ export type StreamQuery = {
mediaType?: 'podcast' | 'song'; mediaType?: 'podcast' | 'song';
offset?: number; offset?: number;
transcode: boolean; transcode: boolean;
transcodeParams?: string;
}; };
export type StructuredLyric = (StructuredSyncedLyric | StructuredUnsyncedLyric) & { export type StructuredLyric = (StructuredSyncedLyric | StructuredUnsyncedLyric) & {
@@ -1780,8 +1787,5 @@ type BaseEndpointArgsWithServer = {
serverId: string; serverId: string;
signal?: AbortSignal; signal?: AbortSignal;
}; };
context?: { context?: ApiContext;
pathReplace?: string;
pathReplaceWith?: string;
};
}; };