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.
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-Forwarded-For $proxy_add_x_forwarded_for;
@ -15,4 +15,4 @@ location /sonarr-series {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}

View File

@ -123,7 +123,7 @@ function keyHandlers(calendar)
case 'ArrowLeft':
calendar.prev();
break;
case 'ArrowRight':
calendar.next();
break;
@ -181,20 +181,17 @@ async function loadSonarrCalendar(shouldForce = false)
const calendarElement = document.querySelector('#sonarr-calendar');
let events = [];
let promises = [];
for (const list of icsUrls)
{
try {
const { url, name } = list;
let fetched = await fetchIcs(url, name, shouldForce);
fetched = fetched.filter(x => x !== null);
events = [...events, ...fetched];
}
catch (err) {
console.error(err);
}
const { url, name } = list;
promises.push(fetchIcs(url, name, shouldForce));
}
events = await Promise.all(promises);
events = events.flat();
events = events.filter(x => x !== null);
const calendar = new FullCalendar.Calendar(calendarElement, {
// initialView: 'dayGridMonth',
customButtons: {
@ -220,7 +217,7 @@ async function loadSonarrCalendar(shouldForce = false)
const message = document.querySelector('#status-message');
try {
calendar.render();
if (message) {
message.textContent = '';
}
@ -244,4 +241,4 @@ window.addEventListener('DOMContentLoaded', function() {
},
60 * 1000
);
});
});