calendar_hot_fixes (#3571)

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov 2023-08-08 19:17:35 +06:00 committed by GitHub
parent 07cc690d23
commit 58dfa9d4a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 17 deletions

View File

@ -227,21 +227,21 @@ function getReccuringEventInstances (
to: Timestamp
): ReccuringInstance[] {
let res: ReccuringInstance[] = []
for (const rule of event.rules) {
for (const rule of event.rules ?? []) {
const values = generateRecurringValues(rule, event.date, from, to)
for (const val of values) {
const instance = getInstance(event, val)
res.push(instance)
}
}
for (const date of event.rdate) {
for (const date of event.rdate ?? []) {
if (date < from || date > to) continue
const instance = getInstance(event, date)
const exists = res.find((p) => p.date === instance.date)
if (exists === undefined) res.push(instance)
}
const excludes = new Set(event.exdate)
const excludes = new Set(event.exdate ?? [])
res = res.filter((p) => !excludes.has(p.date))
res = res.filter((i) => {
const override = instances.find((p) => p.originalStartTime === i.date)

View File

@ -113,20 +113,9 @@ async function onEventCreate (tx: Tx, control: TriggerControl): Promise<Tx[]> {
(p) => (p._id !== ev.createdBy ?? ev.modifiedBy) && ev.participants.includes(p.person)
)
for (const acc of participants) {
const innerTx = control.txFactory.createTxCreateDoc(ev._class, `${acc._id}_calendar` as Ref<Calendar>, {
eventId: ev.eventId,
participants: ev.participants,
externalParticipants: ev.externalParticipants,
title: ev.title,
description: ev.description,
allDay: ev.allDay,
attachedTo: ev.attachedTo,
attachedToClass: ev.attachedToClass,
collection: ev.collection,
date: ev.date,
dueDate: ev.dueDate,
reminders: ev.reminders,
location: ev.location,
const { _id, _class, space, modifiedBy, modifiedOn, ...data } = ev
const innerTx = control.txFactory.createTxCreateDoc(_class, `${acc._id}_calendar` as Ref<Calendar>, {
...data,
access: 'reader'
})
res.push(