This commit is contained in:
Timothy Z. 2026-05-19 23:22:20 +03:00 committed by GitHub
commit 1b06be9ba0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 62 additions and 0 deletions

View file

@ -27,6 +27,15 @@ type StreamingServerSettings = {
transcodeProfile: string | null,
};
type StreamingServerSettingsOption = {
id: string,
label: string,
selections?: {
name: string,
val: string | number | null,
}[],
};
type SFile = {
name: string,
path: string,
@ -122,6 +131,7 @@ type StreamingServer = {
remoteUrl: string | null,
selected: Selected | null,
settings: Loadable<StreamingServerSettings> | null,
settingsOptions: StreamingServerSettingsOption[],
torrent: [string, Loadable<Torrent>] | null,
statistics: Loadable<Statistics> | null,
playbackDevices: Loadable<PlaybackDevice[]> | null,

View file

@ -21,6 +21,7 @@ const Streaming = forwardRef<HTMLDivElement, Props>(({ profile, streamingServer
streamingServerRemoteUrlInput,
remoteEndpointSelect,
cacheSizeSelect,
cacheLocationSelect,
torrentProfileSelect,
transcodingProfileSelect,
} = useStreamingOptions(streamingServer);
@ -67,6 +68,15 @@ const Streaming = forwardRef<HTMLDivElement, Props>(({ profile, streamingServer
/>
</Option>
}
{
cacheLocationSelect !== null &&
<Option label={'SETTINGS_CACHING_DRIVE'}>
<MultiselectMenu
className={'multiselect'}
{...cacheLocationSelect}
/>
</Option>
}
{
torrentProfileSelect !== null &&
<Option label={'SETTINGS_SERVER_TORRENT_PROFILE'}>

View file

@ -81,6 +81,10 @@ const useStreamingOptions = (streamingServer: StreamingServer) => {
streamingServer.deviceInfo.content as DeviceInfo : null
), [streamingServer.deviceInfo]);
const cacheRootOption = useMemo(() => {
return streamingServer.settingsOptions?.find(({ id }) => id === 'cacheRoot') ?? null;
}, [streamingServer.settingsOptions]);
const streamingServerRemoteUrlInput = useMemo(() => ({
value: streamingServer.remoteUrl,
}), [streamingServer.remoteUrl]);
@ -146,6 +150,43 @@ const useStreamingOptions = (streamingServer: StreamingServer) => {
};
}, [settings]);
const cacheLocationSelect = useMemo(() => {
if (!settings || !cacheRootOption?.selections?.length) {
return null;
}
const options = cacheRootOption.selections
.filter(({ val }) => typeof val === 'string')
.map(({ name, val }) => ({
label: name,
value: val as string,
}));
if (!options.length) {
return null;
}
return {
options,
value: settings.cacheRoot,
title: () => {
return settings.cacheRoot;
},
onSelect: (value: string) => {
core.transport.dispatch({
action: 'StreamingServer',
args: {
action: 'UpdateSettings',
args: {
...settings,
cacheRoot: value,
}
}
});
}
};
}, [settings, cacheRootOption]);
const torrentProfileSelect = useMemo(() => {
if (!settings) {
return null;
@ -229,6 +270,7 @@ const useStreamingOptions = (streamingServer: StreamingServer) => {
streamingServerRemoteUrlInput,
remoteEndpointSelect,
cacheSizeSelect,
cacheLocationSelect,
torrentProfileSelect,
transcodingProfileSelect,
};