mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-05-24 16:42:30 +00:00
Merge 3894b1c7d9 into 87ccc591df
This commit is contained in:
commit
1b06be9ba0
3 changed files with 62 additions and 0 deletions
10
src/core/types/models/StremingServer.d.ts
vendored
10
src/core/types/models/StremingServer.d.ts
vendored
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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'}>
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue