소스 검색

Prevent duplicate CalDAV availability slots for recurring slots

If there is the same time slot for more than one day, then we wrote two
recurring AVAILABILITY components before. With this patch equal blocks
are combined into one recurring component. This makes the generated
rules more compact and easier to work with.

Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
tags/v23.0.0beta2
Christoph Wurst 2 년 전
부모
커밋
e23a38e486
No account linked to committer's email address
4개의 변경된 파일31개의 추가작업 그리고 7개의 파일을 삭제
  1. 2
    0
      .gitattributes
  2. 1
    1
      apps/dav/js/settings-personal-availability.js
  3. 1
    1
      apps/dav/js/settings-personal-availability.js.map
  4. 27
    5
      apps/dav/src/service/CalendarService.js

+ 2
- 0
.gitattributes 파일 보기

@@ -7,6 +7,8 @@
/apps/comments/js/*.js.map binary
/apps/dashboard/js/*.js binary
/apps/dashboard/js/*.js.map binary
/apps/dav/js/*.js binary
/apps/dav/js/*.js.map binary
/apps/files/js/dist/*.js binary
/apps/files/js/dist/*.js.map binary
/apps/files_sharing/js/dist/*.js binary

+ 1
- 1
apps/dav/js/settings-personal-availability.js
파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
파일 보기


+ 1
- 1
apps/dav/js/settings-personal-availability.js.map
파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
파일 보기


+ 27
- 5
apps/dav/src/service/CalendarService.js 파일 보기

@@ -100,15 +100,37 @@ export async function saveScheduleInboxAvailability(slots, timezoneId) {
})))]

const vavailabilityComp = new ICAL.Component('vavailability')
// TODO: deduplicate slots that occur on more than one day
all.map(slot => {

// Deduplicate by start and end time
const deduplicated = all.reduce((acc, slot) => {
const key = [
slot.start.getHours(),
slot.start.getMinutes(),
slot.end.getHours(),
slot.end.getMinutes(),
].join('-')

return {
...acc,
[key]: [...(acc[key] ?? []), slot],
}
}, {})

// Create an AVAILABILITY component for every recurring slot
Object.keys(deduplicated).map(key => {
const slots = deduplicated[key]
const start = slots[0].start
const end = slots[0].end
// Combine days but make them also unique
const days = slots.map(slot => slot.day).filter((day, index, self) => self.indexOf(day) === index)

const availableComp = new ICAL.Component('available')

// Define DTSTART and DTEND
// TODO: tz? moment.tz(dateTime, timezone).toDate()
const startTimeProp = availableComp.addPropertyWithValue('dtstart', ICAL.Time.fromJSDate(slot.start, false))
const startTimeProp = availableComp.addPropertyWithValue('dtstart', ICAL.Time.fromJSDate(start, false))
startTimeProp.setParameter('tzid', timezoneId)
const endTimeProp = availableComp.addPropertyWithValue('dtend', ICAL.Time.fromJSDate(slot.end, false))
const endTimeProp = availableComp.addPropertyWithValue('dtend', ICAL.Time.fromJSDate(end, false))
endTimeProp.setParameter('tzid', timezoneId)

// Add mandatory UID
@@ -119,7 +141,7 @@ export async function saveScheduleInboxAvailability(slots, timezoneId) {
// Define RRULE
availableComp.addPropertyWithValue('rrule', {
freq: 'WEEKLY',
byday: slot.day,
byday: days,
})

return availableComp

Loading…
취소
저장