Files
sct-overseerr/src/context/SettingsContext.tsx
Gauthier 27112be933 refactor: rename some remaining Overseerr occurrences (#1397)
* refactor: rename some remaining Overseerr occurrences

This PR renames some remaining occurrences of Overseerr to Jellyseerr. This includes the OpenAPI
specification, log file names and some variables and console messages.

* fix(i18n): add missing translation
2025-02-26 13:08:00 +08:00

59 lines
1.4 KiB
TypeScript

import { MediaServerType } from '@server/constants/server';
import type { PublicSettingsResponse } from '@server/interfaces/api/settingsInterfaces';
import React from 'react';
import useSWR from 'swr';
export interface SettingsContextProps {
currentSettings: PublicSettingsResponse;
children?: React.ReactNode;
}
const defaultSettings = {
initialized: false,
applicationTitle: 'Jellyseerr',
applicationUrl: '',
hideAvailable: false,
localLogin: true,
mediaServerLogin: true,
movie4kEnabled: false,
series4kEnabled: false,
discoverRegion: '',
streamingRegion: '',
originalLanguage: '',
mediaServerType: MediaServerType.NOT_CONFIGURED,
partialRequestsEnabled: true,
enableSpecialEpisodes: false,
cacheImages: false,
vapidPublic: '',
enablePushRegistration: false,
locale: 'en',
emailEnabled: false,
newPlexLogin: true,
};
export const SettingsContext = React.createContext<SettingsContextProps>({
currentSettings: defaultSettings,
});
export const SettingsProvider = ({
children,
currentSettings,
}: SettingsContextProps) => {
const { data, error } = useSWR<PublicSettingsResponse>(
'/api/v1/settings/public',
{ fallbackData: currentSettings }
);
let newSettings = defaultSettings;
if (data && !error) {
newSettings = data;
}
return (
<SettingsContext.Provider value={{ currentSettings: newSettings }}>
{children}
</SettingsContext.Provider>
);
};