Skip to content

Commit

Permalink
✨ Add support for multiple Arr services
Browse files Browse the repository at this point in the history
In the calendar, you can now have 2 separate Sonarr or Radarr instances
  • Loading branch information
ajnart committed Jun 6, 2022
1 parent e2f5938 commit 6fd23cf
Showing 1 changed file with 41 additions and 23 deletions.
64 changes: 41 additions & 23 deletions src/components/modules/calendar/CalendarModule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,29 +41,47 @@ export default function CalendarComponent(props: any) {
}

useEffect(() => {
// Filter only sonarr and radarr services

// Get the url and apiKey for all Sonarr and Radarr services
sonarrServices.map((service) =>
getMedias(service, 'sonarr').then((res) => {
setSonarrMedias([...sonarrMedias, ...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]);
})
);
// Create each Sonarr service and get the medias
const currentSonarrMedias: any[] = [...sonarrMedias];
Promise.all(
sonarrServices.map((service) =>
getMedias(service, 'sonarr').then((res) => {
currentSonarrMedias.push(...res.data);
})
)
).then(() => {
setSonarrMedias(currentSonarrMedias);
});
const currentRadarrMedias: any[] = [...radarrMedias];
Promise.all(
radarrServices.map((service) =>
getMedias(service, 'radarr').then((res) => {
currentRadarrMedias.push(...res.data);
})
)
).then(() => {
setRadarrMedias(currentRadarrMedias);
});
const currentLidarrMedias: any[] = [...lidarrMedias];
Promise.all(
lidarrServices.map((service) =>
getMedias(service, 'lidarr').then((res) => {
currentLidarrMedias.push(...res.data);
})
)
).then(() => {
setLidarrMedias(currentLidarrMedias);
});
const currentReadarrMedias: any[] = [...readarrMedias];
Promise.all(
readarrServices.map((service) =>
getMedias(service, 'readarr').then((res) => {
currentReadarrMedias.push(...res.data);
})
)
).then(() => {
setReadarrMedias(currentReadarrMedias);
});
}, [config.services]);

return (
Expand Down

0 comments on commit 6fd23cf

Please sign in to comment.