From ae2ce0866e6d61a6a5a56c027358c32d6db6404b Mon Sep 17 00:00:00 2001 From: jeffvli Date: Tue, 31 Mar 2026 01:20:25 -0700 Subject: [PATCH] include transcode settings and server features in api context --- src/renderer/api/controller.ts | 15 +++++++++++++++ src/shared/types/domain-types.ts | 24 ++++++++++++++---------- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/src/renderer/api/controller.ts b/src/renderer/api/controller.ts index 97f7b06ad..ddd336c0a 100644 --- a/src/renderer/api/controller.ts +++ b/src/renderer/api/controller.ts @@ -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 = (args: T): T => { const pathSettings = getPathReplaceSettings(); + const transcodeSettings = getTranscodeSettings(); + const serverFeatures = getServerFeatures(); + return { ...args, context: { ...(args.context || {}), ...pathSettings, + serverFeatures: serverFeatures, + transcode: transcodeSettings, }, }; }; diff --git a/src/shared/types/domain-types.ts b/src/shared/types/domain-types.ts index 69fc46e9f..a8a0d2906 100644 --- a/src/shared/types/domain-types.ts +++ b/src/shared/types/domain-types.ts @@ -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) => Promise; getSongList: (args: ReplaceApiClientProps) => Promise; getSongListCount: (args: ReplaceApiClientProps) => Promise; - getStreamUrl: (args: ReplaceApiClientProps) => string; + getStreamUrl: (args: ReplaceApiClientProps) => Promise; getStructuredLyrics?: ( args: ReplaceApiClientProps, ) => Promise; @@ -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; };