Use Config provider everywhere in app

We can now load as much data as we want in the services and settings values. This solves the issue of using multiple localStorages boxes
This commit is contained in:
Aj - Thomas
2022-05-02 15:09:39 +02:00
parent ea77bc2a18
commit c95df0a07b
8 changed files with 83 additions and 109 deletions

View File

@@ -4,14 +4,14 @@ import { Calendar } from '@mantine/dates';
import dayjs from 'dayjs';
import MediaDisplay from './MediaDisplay';
import { medias } from './mediaExample';
import { useServices } from '../../tools/state';
import { useConfig } from '../../tools/state';
async function GetCalendars(endDate: Date) {
// Load context
const { services, addService, removeService, setServicesState } = useServices();
const { config, addService, removeService, setConfig } = useConfig();
// Load services that have the type to "Sonarr" or "Radarr"
const sonarrServices = services.filter((service) => service.type === 'Sonarr');
const radarrServices = services.filter((service) => service.type === 'Radarr');
const sonarrServices = config.services.filter((service) => service.type === 'Sonarr');
const radarrServices = config.services.filter((service) => service.type === 'Radarr');
// Merge the two arrays
const allServices = [...sonarrServices, ...radarrServices];
// Load the calendars for each service