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 };
};
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,
},
};
};
+14 -10
View File
@@ -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;
};