@@ -209,12 +209,11 @@ const sessionState = reactive({
209
209
showSessionDialog: false ,
210
210
})
211
211
212
- async function getCalendarEvents ({ start, end }) {
213
- const params = {
214
- " startDate[after]" : start .toISOString (),
215
- " endDate[before]" : end .toISOString (),
216
- }
217
-
212
+ /**
213
+ * @param {Object} params
214
+ * @returns {Promise<Array<Object>>}
215
+ */
216
+ async function getCalendarEvents (params ) {
218
217
if (course .value ) {
219
218
params .cid = course .value .id
220
219
}
@@ -331,8 +330,36 @@ const calendarOptions = ref({
331
330
332
331
dialog .value = true
333
332
},
334
- events (info , successCallback ) {
335
- getCalendarEvents (info).then ((events ) => successCallback (events))
333
+ async events (info , successCallback ) {
334
+ const endingEventsPromise = getCalendarEvents ({
335
+ " endDate[before]" : info .end .toISOString (),
336
+ " endDate[after]" : info .start .toISOString (),
337
+ })
338
+
339
+ const currentEventsPromise = getCalendarEvents ({
340
+ " endDate[before]" : info .end .toISOString (),
341
+ " startDate[after]" : info .start .toISOString (),
342
+ })
343
+
344
+ const startingEventsPromise = getCalendarEvents ({
345
+ " startDate[before]" : info .end .toISOString (),
346
+ " startDate[after]" : info .start .toISOString (),
347
+ })
348
+
349
+ const [endingEvents , currentEvents , startingEvents ] = await Promise .all ([
350
+ endingEventsPromise,
351
+ currentEventsPromise,
352
+ startingEventsPromise,
353
+ ])
354
+
355
+ const uniqueEventsMap = new Map ()
356
+
357
+ endingEvents
358
+ .concat (currentEvents)
359
+ .concat (startingEvents)
360
+ .forEach ((event ) => uniqueEventsMap .set (event .id , event ))
361
+
362
+ successCallback (Array .from (uniqueEventsMap .values ()))
336
363
},
337
364
})
338
365
0 commit comments