// Settings page: "Discover calendars" against the CalDAV account already // saved on this form (same idiom as frame_photos.js's Load Albums using // the frame's already-saved Immich creds) -- so this only works after // the CalDAV URL/username/password have been saved once. const discoverBtn = document.getElementById('caldav-discover'); if (discoverBtn) { discoverBtn.addEventListener('click', async () => { const list = document.getElementById('caldav-calendar-list'); discoverBtn.disabled = true; try { const resp = await fetch('/api/settings/caldav-discover', { method: 'POST' }); if (!resp.ok) throw new Error(await apiError(resp)); const calendars = await resp.json(); list.innerHTML = ''; if (calendars.length === 0) { list.innerHTML = '