diff --git a/backend/src/routes/search.js b/backend/src/routes/search.js index 8567e6a..dc0c25c 100644 --- a/backend/src/routes/search.js +++ b/backend/src/routes/search.js @@ -71,12 +71,6 @@ router.post('/sync-calendar', authenticate, async (req, res) => { } } - const ins = db.prepare(` - INSERT INTO calendar_event_cache - (feed_id, user_id, summary, description, location, start_dt, end_dt, synced_at) - VALUES (?,?,?,?,?,?,?,datetime('now','localtime')) - `); - let totalSynced = 0; const errors = []; @@ -85,16 +79,27 @@ router.post('/sync-calendar', authenticate, async (req, res) => { const raw = await fetchIcal(feed.url); if (!raw) { errors.push(`${feed.name}: kein gültiger iCal-Feed`); continue; } const events = parseIcal(raw); + if (!events.length) { errors.push(`${feed.name}: 0 Events geparst`); continue; } + // prepare INSIDE try-catch – wirft wenn Tabelle nicht existiert + const ins = db.prepare(` + INSERT INTO calendar_event_cache + (feed_id, user_id, summary, description, location, start_dt, end_dt, synced_at) + VALUES (?,?,?,?,?,?,?,datetime('now','localtime')) + `); db.transaction(() => { db.prepare('DELETE FROM calendar_event_cache WHERE feed_id=?').run(feed.id); events.slice(0, 300).forEach(ev => - ins.run(feed.id, uid, ev.summary, ev.description, ev.location, ev.start, ev.end) + ins.run(feed.id, uid, ev.summary||'', ev.description||'', ev.location||'', ev.start||'', ev.end||'') ); })(); totalSynced += events.length; - } catch(e) { errors.push(`${feed.name}: ${e.message}`); } + } catch(e) { + console.error(`[CalendarSync] Feed "${feed.name}" (${feed.url}): ${e.message}`); + errors.push(`${feed.name}: ${e.message}`); + } } + console.log(`[CalendarSync] uid=${uid} synced=${totalSynced} feeds=${feeds.length} errors=${errors.length}`); res.json({ ok: true, synced: totalSynced, feeds: feeds.length, errors }); }); diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index 260e887..c05e611 100644 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -1859,9 +1859,9 @@ function GlobalSearch({ setActive, setDevToolsNav, mobile }) { )} - {/* Backdrop zum Schließen */} + {/* Backdrop zum Schließen – leicht opak damit Dashboard nicht durchscheint */} {showDropdown && ( -