From 0b4060beae5cc43545760786001fcfaac2826b54 Mon Sep 17 00:00:00 2001 From: Scarriffle Date: Tue, 7 Apr 2026 22:18:10 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20Kalenderfarbe=20wird=20sofort=20ohne=20R?= =?UTF-8?q?eload=20aktualisiert=20Statt=20nach=20Farb=C3=A4nderung=20den?= =?UTF-8?q?=20Cache=20zu=20invalidieren=20und=20neu=20zu=20laden,=20wird?= =?UTF-8?q?=20calendarColor=20direkt=20in-place=20auf=20allen=20gecachten?= =?UTF-8?q?=20Events=20gepatcht=20und=20dann=20nur=20renderView()=20aufger?= =?UTF-8?q?ufen.=20Kein=20Netzwerk-Request,=20sofortige=20Darstellung=20de?= =?UTF-8?q?r=20neuen=20Farbe.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/js/calendar.js | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/frontend/js/calendar.js b/frontend/js/calendar.js index 3dca0ac..e177cb7 100644 --- a/frontend/js/calendar.js +++ b/frontend/js/calendar.js @@ -98,6 +98,22 @@ function _mergeEvents(newEvents) { } } +// Patch calendarColor in-place for all cached events belonging to a calendar, +// then re-render immediately without a network round-trip. +function applyCalendarColor(source, calId, color) { + const id = String(calId); + eventCache.events.forEach(ev => { + if (ev.source !== source) return; + const cid = String(ev.calendar_id); + if (cid === id || cid === source + '-' + id || cid.replace(source + '-', '') === id) { + ev.calendarColor = color; + } + }); + state.events = eventCache.events; + renderCalendarList(); + renderView(); +} + // Fire-and-forget: extend the cache toward whichever edge the view is approaching function prefetchIfNeeded(viewStart, viewEnd) { if (!eventCache.start || !eventCache.end) return; @@ -468,8 +484,7 @@ function renderCalendarList() { if (picked) { await api.put(`/local/calendars/${calId}`, { color: picked }); if (cal) cal.color = picked; - renderCalendarList(); - fetchAndRender(); + applyCalendarColor('local', calId, picked); } } else if (source === 'ical') { const subId = parseInt(dot.dataset.subId); @@ -478,8 +493,7 @@ function renderCalendarList() { if (picked) { await api.put(`/ical/subscriptions/${subId}`, { color: picked }); if (sub) sub.color = picked; - renderCalendarList(); - fetchAndRender(); + applyCalendarColor('ical', subId, picked); } } else if (source === 'google') { const calId = parseInt(dot.dataset.calId); @@ -492,8 +506,7 @@ function renderCalendarList() { if (picked) { await api.put(`/google/calendars/${calId}`, { color: picked }); if (gcal) gcal.color = picked; - renderCalendarList(); - fetchAndRender(); + applyCalendarColor('google', calId, picked); } } }); @@ -1732,8 +1745,7 @@ async function openCalColorPicker(anchor, calId) { if (cal.id === calId) cal.color = picked; } } - renderCalendarList(); - fetchAndRender(); + applyCalendarColor('caldav', calId, picked); } // ── Avatar Crop ──────────────────────────────────────────