mirror of
https://github.com/sct/overseerr.git
synced 2025-12-26 08:25:07 +01:00
feat: 4K Requests (#559)
This commit is contained in:
39
src/context/SettingsContext.tsx
Normal file
39
src/context/SettingsContext.tsx
Normal file
@@ -0,0 +1,39 @@
|
||||
import React from 'react';
|
||||
import { PublicSettingsResponse } from '../../server/interfaces/api/settingsInterfaces';
|
||||
import useSWR from 'swr';
|
||||
|
||||
interface SettingsContextProps {
|
||||
currentSettings: PublicSettingsResponse;
|
||||
}
|
||||
|
||||
const defaultSettings = {
|
||||
initialized: false,
|
||||
movie4kEnabled: false,
|
||||
series4kEnabled: false,
|
||||
};
|
||||
|
||||
export const SettingsContext = React.createContext<SettingsContextProps>({
|
||||
currentSettings: defaultSettings,
|
||||
});
|
||||
|
||||
export const SettingsProvider: React.FC<SettingsContextProps> = ({
|
||||
children,
|
||||
currentSettings,
|
||||
}) => {
|
||||
const { data, error } = useSWR<PublicSettingsResponse>(
|
||||
'/api/v1/settings/public',
|
||||
{ initialData: currentSettings }
|
||||
);
|
||||
|
||||
let newSettings = defaultSettings;
|
||||
|
||||
if (data && !error) {
|
||||
newSettings = data;
|
||||
}
|
||||
|
||||
return (
|
||||
<SettingsContext.Provider value={{ currentSettings: newSettings }}>
|
||||
{children}
|
||||
</SettingsContext.Provider>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user