Skip to content

Commit 9b6238a

Browse files
Read and write time zone ID when updating CalDAV availability
Tiny bug/limitation of #27466 Signed-off-by: Christoph Wurst <[email protected]>
1 parent d231d26 commit 9b6238a

File tree

4 files changed

+23
-7
lines changed

4 files changed

+23
-7
lines changed

apps/dav/js/settings-personal-availability.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/dav/js/settings-personal-availability.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/dav/src/service/CalendarService.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,14 @@ export async function findScheduleInboxAvailability() {
6464

6565
const vcalendarComp = new ICAL.Component(parsedIcal)
6666
const vavailabilityComp = vcalendarComp.getFirstSubcomponent('vavailability')
67-
const availableComps = vavailabilityComp.getAllSubcomponents('available')
6867

68+
let timezoneId
69+
const timezoneComp = vcalendarComp.getFirstSubcomponent('vtimezone')
70+
if (timezoneComp) {
71+
timezoneId = timezoneComp.getFirstProperty('tzid').getFirstValue()
72+
}
73+
74+
const availableComps = vavailabilityComp.getAllSubcomponents('available')
6975
// Combine all AVAILABLE blocks into a week of slots
7076
const slots = getEmptySlots()
7177
availableComps.forEach((availableComp) => {
@@ -90,6 +96,7 @@ export async function findScheduleInboxAvailability() {
9096

9197
return {
9298
slots,
99+
timezoneId,
93100
}
94101
}
95102

@@ -99,6 +106,14 @@ export async function saveScheduleInboxAvailability(slots, timezoneId) {
99106
day: dayId,
100107
})))]
101108

109+
const vcalendarComp = new ICAL.Component('vcalendar')
110+
111+
// Store time zone info
112+
const timezoneComp = new ICAL.Component('vtimezone')
113+
timezoneComp.addPropertyWithValue('tzid', timezoneId)
114+
vcalendarComp.addSubcomponent(timezoneComp)
115+
116+
// Store availability info
102117
const vavailabilityComp = new ICAL.Component('vavailability')
103118

104119
// Deduplicate by start and end time
@@ -127,7 +142,6 @@ export async function saveScheduleInboxAvailability(slots, timezoneId) {
127142
const availableComp = new ICAL.Component('available')
128143

129144
// Define DTSTART and DTEND
130-
// TODO: tz? moment.tz(dateTime, timezone).toDate()
131145
const startTimeProp = availableComp.addPropertyWithValue('dtstart', ICAL.Time.fromJSDate(start, false))
132146
startTimeProp.setParameter('tzid', timezoneId)
133147
const endTimeProp = availableComp.addPropertyWithValue('dtend', ICAL.Time.fromJSDate(end, false))
@@ -147,7 +161,6 @@ export async function saveScheduleInboxAvailability(slots, timezoneId) {
147161
return availableComp
148162
}).map(vavailabilityComp.addSubcomponent.bind(vavailabilityComp))
149163

150-
const vcalendarComp = new ICAL.Component('vcalendar')
151164
vcalendarComp.addSubcomponent(vavailabilityComp)
152165
logger.debug('New availability ical created', {
153166
asObject: vcalendarComp,

apps/dav/src/views/Availability.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,15 @@ export default {
121121
},
122122
async mounted() {
123123
try {
124-
const { slots } = await findScheduleInboxAvailability()
124+
const { slots, timezoneId } = await findScheduleInboxAvailability()
125125
if (slots) {
126126
this.daysOfTheWeek.forEach(day => {
127127
day.slots.push(...slots[day.id])
128128
})
129129
}
130+
if (timezoneId) {
131+
this.timezone = timezoneId
132+
}
130133
console.info('availability loaded', this.daysOfTheWeek)
131134
} catch (e) {
132135
console.error('could not load existing availability', e)

0 commit comments

Comments
 (0)