Skip to content

Commit d45d11f

Browse files
authored
Minor calendar fixes (#9339)
Signed-off-by: Denis Bykhov <[email protected]>
1 parent a97ad11 commit d45d11f

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

packages/ui/src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,7 @@ export interface CalendarItem {
465465
date: Timestamp
466466
dueDate: Timestamp
467467
day: number
468+
blockTime: boolean
468469
access: 'freeBusyReader' | 'reader' | 'writer' | 'owner'
469470
}
470471

plugins/calendar-resources/src/components/DayCalendar.svelte

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@
118118
allDay: event.allDay,
119119
date: eventStart,
120120
dueDate: eventEnd,
121+
blockTime: event.blockTime,
121122
day,
122123
access: event.access
123124
})
@@ -136,6 +137,7 @@
136137
result.push({
137138
_id: event._id,
138139
allDay: event.allDay,
140+
blockTime: event.blockTime,
139141
date: eventStart,
140142
dueDate: eventEnd,
141143
day: -1,
@@ -343,8 +345,9 @@
343345
}
344346
}
345347
346-
const calcTime = (events: CalendarItem[]): number => {
347-
if (events.length === 0) return 0
348+
const calcTime = (_events: CalendarItem[]): number => {
349+
if (_events.length === 0) return 0
350+
const events = _events.filter((ev) => ev.blockTime)
348351
349352
// Extract and sort intervals by start time
350353
const intervals = events.map((it) => [it.date, it.dueDate]).sort((a, b) => a[0] - b[0])

server-plugins/calendar-resources/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,7 @@ async function onEventCreate (ctx: TxCreateDoc<Event>, control: TriggerControl):
372372
const { _class, space, attachedTo, attachedToClass, collection, ...attr } = event
373373
const data = attr as any as Data<Event>
374374
const calendars = await control.findAll(control.ctx, calendar.class.Calendar, { hidden: false })
375+
const events = await control.findAll(control.ctx, calendar.class.Event, { eventId: event.eventId })
375376
const access = 'reader'
376377
for (const part of event.participants) {
377378
const socialIds = await getSocialIds(control, part as Ref<Person>)
@@ -382,6 +383,7 @@ async function onEventCreate (ctx: TxCreateDoc<Event>, control: TriggerControl):
382383
const user = primarySocialString
383384
const calendar = getCalendar(calendars, socialStrings)
384385
if (calendar === undefined) continue
386+
if (events.find((p) => p.user === user) !== undefined) continue
385387
const innerTx = control.txFactory.createTxCreateDoc(
386388
_class,
387389
space,

0 commit comments

Comments
 (0)