fix: Termin-Änderungen (Farbe, Titel, etc.) sofort ohne Reload anzeigen
Nach dem Speichern eines Termins wird das gecachte Event-Objekt direkt in-place gepatcht und die View neu gerendert. Vorher war die neue Farbe erst nach F5 sichtbar, weil zwar fetchAndRender(true) aufgerufen wurde, aber der Render-Pfad das Update nicht zuverlässig übernommen hat.
This commit is contained in:
@@ -146,6 +146,19 @@ function applyCalendarColor(source, calId, color) {
|
|||||||
renderView();
|
renderView();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Patch a single event in cache after edit/save, then re-render immediately.
|
||||||
|
// 'patch' is the new field values to merge into the existing cached event.
|
||||||
|
function applyEventPatch(eventId, eventUrl, patch) {
|
||||||
|
const targetUrl = eventUrl || '';
|
||||||
|
eventCache.events.forEach(ev => {
|
||||||
|
if (ev.id === eventId && (ev.url || '') === targetUrl) {
|
||||||
|
Object.assign(ev, patch);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
state.events = eventCache.events;
|
||||||
|
renderView();
|
||||||
|
}
|
||||||
|
|
||||||
// Fire-and-forget: extend the cache toward whichever edge the view is approaching
|
// Fire-and-forget: extend the cache toward whichever edge the view is approaching
|
||||||
function prefetchIfNeeded(viewStart, viewEnd) {
|
function prefetchIfNeeded(viewStart, viewEnd) {
|
||||||
if (!eventCache.start || !eventCache.end) return;
|
if (!eventCache.start || !eventCache.end) return;
|
||||||
@@ -1443,6 +1456,13 @@ function bindEventModal() {
|
|||||||
{ title, start, end, allDay, location: loc, description: desc, color: color || null, rrule: rrule || '' }
|
{ title, start, end, allDay, location: loc, description: desc, color: color || null, rrule: rrule || '' }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
// Patch the cached event in-place so the UI reflects changes immediately
|
||||||
|
applyEventPatch(ev.id, ev.url, {
|
||||||
|
title, start, end, allDay,
|
||||||
|
location: loc, description: desc,
|
||||||
|
color: color || null,
|
||||||
|
rrule: rrule || null,
|
||||||
|
});
|
||||||
showToast(t('event_updated'));
|
showToast(t('event_updated'));
|
||||||
} else if (isGoogle) {
|
} else if (isGoogle) {
|
||||||
const calDbId = parseInt(calVal.replace('google-', ''));
|
const calDbId = parseInt(calVal.replace('google-', ''));
|
||||||
|
|||||||
Reference in New Issue
Block a user