Fix calendar fetch on homepage

This commit is contained in:
Alex Thomassen 2024-08-19 22:19:51 +02:00
parent 1a2c873658
commit 7101d583cc
3 changed files with 30 additions and 15 deletions

18
.editorconfig Normal file
View File

@ -0,0 +1,18 @@
root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false
[*.{yml,yaml}]
indent_size = 2
[docker-compose.yml]
indent_size = 4

View File

@ -2,7 +2,7 @@
# Since that normally requires the API key, which you normally don't want to expose to the public. # Since that normally requires the API key, which you normally don't want to expose to the public.
location /sonarr-ics { location /sonarr-ics {
proxy_pass "https://sonarr.example.com/feed/calendar/Sonarr.ics?apikey=YOUR_API_KEY_HERE"; proxy_pass "https://sonarr.example.com/feed/v3/calendar/Sonarr.ics?apikey=YOUR_API_KEY_HERE";
proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

View File

@ -181,19 +181,16 @@ async function loadSonarrCalendar(shouldForce = false)
const calendarElement = document.querySelector('#sonarr-calendar'); const calendarElement = document.querySelector('#sonarr-calendar');
let events = []; let events = [];
let promises = [];
for (const list of icsUrls) for (const list of icsUrls)
{ {
try {
const { url, name } = list; const { url, name } = list;
let fetched = await fetchIcs(url, name, shouldForce); promises.push(fetchIcs(url, name, shouldForce));
fetched = fetched.filter(x => x !== null); }
events = [...events, ...fetched]; events = await Promise.all(promises);
} events = events.flat();
catch (err) { events = events.filter(x => x !== null);
console.error(err);
}
}
const calendar = new FullCalendar.Calendar(calendarElement, { const calendar = new FullCalendar.Calendar(calendarElement, {
// initialView: 'dayGridMonth', // initialView: 'dayGridMonth',