mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-11 07:55:52 +01:00
✨ Add support for multiple same service in Calendar
Fixes Calendar Support for Multiple Sonarr / Radarr #176
This commit is contained in:
@@ -28,10 +28,10 @@ export default function CalendarComponent(props: any) {
|
|||||||
const [lidarrMedias, setLidarrMedias] = useState([] as any);
|
const [lidarrMedias, setLidarrMedias] = useState([] as any);
|
||||||
const [radarrMedias, setRadarrMedias] = useState([] as any);
|
const [radarrMedias, setRadarrMedias] = useState([] as any);
|
||||||
const [readarrMedias, setReadarrMedias] = useState([] as any);
|
const [readarrMedias, setReadarrMedias] = useState([] as any);
|
||||||
const sonarrService = config.services.filter((service) => service.type === 'Sonarr').at(0);
|
const sonarrServices = config.services.filter((service) => service.type === 'Sonarr');
|
||||||
const radarrService = config.services.filter((service) => service.type === 'Radarr').at(0);
|
const radarrServices = config.services.filter((service) => service.type === 'Radarr');
|
||||||
const lidarrService = config.services.filter((service) => service.type === 'Lidarr').at(0);
|
const lidarrServices = config.services.filter((service) => service.type === 'Lidarr');
|
||||||
const readarrService = config.services.filter((service) => service.type === 'Readarr').at(0);
|
const readarrServices = config.services.filter((service) => service.type === 'Readarr');
|
||||||
|
|
||||||
function getMedias(service: serviceItem | undefined, type: string) {
|
function getMedias(service: serviceItem | undefined, type: string) {
|
||||||
if (!service || !service.apiKey) {
|
if (!service || !service.apiKey) {
|
||||||
@@ -44,10 +44,26 @@ export default function CalendarComponent(props: any) {
|
|||||||
// Filter only sonarr and radarr services
|
// Filter only sonarr and radarr services
|
||||||
|
|
||||||
// Get the url and apiKey for all Sonarr and Radarr services
|
// Get the url and apiKey for all Sonarr and Radarr services
|
||||||
getMedias(sonarrService, 'sonarr').then((res) => setSonarrMedias(res.data));
|
sonarrServices.map((service) =>
|
||||||
getMedias(radarrService, 'radarr').then((res) => setRadarrMedias(res.data));
|
getMedias(service, 'sonarr').then((res) => {
|
||||||
getMedias(lidarrService, 'lidarr').then((res) => setLidarrMedias(res.data));
|
setSonarrMedias([...sonarrMedias, ...res.data]);
|
||||||
getMedias(readarrService, 'readarr').then((res) => setReadarrMedias(res.data));
|
})
|
||||||
|
);
|
||||||
|
radarrServices.map((service) =>
|
||||||
|
getMedias(service, 'radarr').then((res) => {
|
||||||
|
setRadarrMedias([...radarrMedias, ...res.data]);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
lidarrServices.map((service) =>
|
||||||
|
getMedias(service, 'lidarr').then((res) => {
|
||||||
|
setLidarrMedias([...lidarrMedias, ...res.data]);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
readarrServices.map((service) =>
|
||||||
|
getMedias(service, 'readarr').then((res) => {
|
||||||
|
setReadarrMedias([...readarrMedias, ...res.data]);
|
||||||
|
})
|
||||||
|
);
|
||||||
}, [config.services]);
|
}, [config.services]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user