fix: store VTIMEZONEs as raw jCal arrays for Vue reactivity safety
ICAL.Component instances break when wrapped by Vue's reactive proxy (the .jCal getter returns undefined through the proxy, causing serializeICS to crash with 'Cannot read properties of undefined'). Storing vtz.jCal (plain arrays) instead makes meta fully serializable for both reactivity and JSON snapshot cloning.
This commit is contained in:
@@ -111,7 +111,9 @@ export function parseICS(text) {
|
||||
method: vcalendar.getFirstPropertyValue('method') || null,
|
||||
xWrCalname: vcalendar.getFirstPropertyValue('x-wr-calname') || null,
|
||||
xWrTimezone: vcalendar.getFirstPropertyValue('x-wr-timezone') || null,
|
||||
vtimezones: vcalendar.getAllSubcomponents('vtimezone'),
|
||||
// Store raw jCal arrays (not ICAL.Component instances) so the meta stays
|
||||
// plain-serializable for Vue reactivity and JSON snapshot cloning.
|
||||
vtimezones: vcalendar.getAllSubcomponents('vtimezone').map((vtz) => vtz.jCal),
|
||||
}
|
||||
|
||||
// Events
|
||||
@@ -185,9 +187,10 @@ export function serializeICS({ meta, events }) {
|
||||
if (meta.xWrCalname) vcalendar.updatePropertyWithValue('x-wr-calname', meta.xWrCalname)
|
||||
if (meta.xWrTimezone) vcalendar.updatePropertyWithValue('x-wr-timezone', meta.xWrTimezone)
|
||||
|
||||
// Re-add VTIMEZONEs (clone jCal to avoid moving from original parent)
|
||||
for (const vtz of meta.vtimezones || []) {
|
||||
vcalendar.addSubcomponent(new ICAL.Component(vtz.jCal))
|
||||
// Re-add VTIMEZONEs. meta.vtimezones stores raw jCal arrays (see parseICS),
|
||||
// so wrap each directly in a new Component (avoids moving the original).
|
||||
for (const vtzJCal of meta.vtimezones || []) {
|
||||
vcalendar.addSubcomponent(new ICAL.Component(vtzJCal))
|
||||
}
|
||||
|
||||
for (const ev of events) {
|
||||
|
||||
Reference in New Issue
Block a user