Skip to content

Commit 3cdd8d3

Browse files
committed
fix(imip): use default calendar if possible
Signed-off-by: Richard Steinmetz <richard@steinmetz.cloud>
1 parent c59cf84 commit 3cdd8d3

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

src/components/Imip.vue

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@
5151
:aria-label-combobox="t('mail', 'Select')"
5252
label="displayname"
5353
:options="calendarsForPicker">
54-
<template #option="{option}">
54+
<template #option="option">
5555
<CalendarPickerOption v-bind="option" />
5656
</template>
57-
<template #singleLabel="{option}">
58-
<CalendarPickerOption :display-icon="true" v-bind="option" />
57+
<template #selected-option="option">
58+
<CalendarPickerOption v-bind="option" />
5959
</template>
6060
</NcSelect>
6161
</div>
@@ -196,6 +196,7 @@ export default {
196196
...mapState(useMainStore, {
197197
currentUserPrincipalEmail: 'getCurrentUserPrincipalEmail',
198198
clonedWriteableCalendars: 'getClonedWriteableCalendars',
199+
currentUserPrincipal: 'getCurrentUserPrincipal',
199200
}),
200201

201202
/**
@@ -367,14 +368,23 @@ export default {
367368
},
368369
writable: calendar.currentUserPrivilegeSet.indexOf('{DAV:}write') !== -1,
369370
url: calendar.url,
370-
dav: calendar,
371371
}
372372
}
373373

374374
return this.clonedWriteableCalendars
375375
.map(getCalendarData)
376376
.filter(props => props.components.vevent && props.writable === true)
377377
},
378+
379+
/**
380+
* Get the DAV object of the picked target calendar.
381+
* It can't be included in the option as it contains cyclic references.
382+
*
383+
* @return {object | undefined}
384+
*/
385+
targetCalendarDavObject() {
386+
return this.clonedWriteableCalendars.find((cal) => cal.url === this.targetCalendar.url)
387+
}
378388
},
379389
watch: {
380390
attachedVEvent: {
@@ -386,7 +396,16 @@ export default {
386396
calendarsForPicker: {
387397
immediate: true,
388398
handler(calendarsForPicker) {
389-
if (calendarsForPicker.length > 0 && !this.targetCalendar) {
399+
if (this.targetCalendar) {
400+
return
401+
}
402+
403+
const defaultCalendar = calendarsForPicker.find(
404+
(cal) => cal.url === this.currentUserPrincipal.scheduleDefaultCalendarUrl
405+
)
406+
if (defaultCalendar) {
407+
this.targetCalendar = defaultCalendar
408+
} else if (calendarsForPicker.length > 0) {
390409
this.targetCalendar = calendarsForPicker[0]
391410
}
392411
},
@@ -415,7 +434,7 @@ export default {
415434
return
416435
}
417436

418-
const calendar = this.targetCalendar?.dav
437+
const calendar = this.targetCalendarDavObject
419438
if (!calendar) {
420439
return
421440
}

0 commit comments

Comments
 (0)