Преглед изворни кода

Handle all day events in calendar

j8
Bettenbuk Zoltan пре 6 година
родитељ
комит
61456b0d99
1 измењених фајлова са 22 додато и 2 уклоњено
  1. 22
    2
      react/features/calendar-sync/functions.any.js

+ 22
- 2
react/features/calendar-sync/functions.any.js Прегледај датотеку

@@ -7,6 +7,25 @@ import { APP_LINK_SCHEME, parseURIString } from '../base/util';
7 7
 import { MAX_LIST_LENGTH } from './constants';
8 8
 
9 9
 const logger = require('jitsi-meet-logger').getLogger(__filename);
10
+const ALLDAY_EVENT_LENGTH = 23 * 60 * 60 * 1000;
11
+
12
+/**
13
+ * Returns true of the calendar entry is to be displayed in the app, false
14
+ * otherwise.
15
+ *
16
+ * @param {Object} entry - The calendar entry.
17
+ * @returns {boolean}
18
+ */
19
+function _isDisplayableCalendarEntry(entry) {
20
+    // Entries are displayable if:
21
+    //   - Ends in the future (future or ongoing events)
22
+    //   - Is not an all day event and there is only one attendee (these events
23
+    //     are usually placeholder events that don't need to be shown.)
24
+    return entry.endDate > Date.now()
25
+        && !((entry.allDay
26
+                || entry.endDate - entry.startDate > ALLDAY_EVENT_LENGTH)
27
+                    && (!entry.attendees || entry.attendees.length < 2));
28
+}
10 29
 
11 30
 /**
12 31
  * Updates the calendar entries in redux when new list is received. The feature
@@ -29,13 +48,12 @@ export function _updateCalendarEntries(events: Array<Object>) {
29 48
     // eslint-disable-next-line no-invalid-this
30 49
     const { dispatch, getState } = this;
31 50
     const knownDomains = getState()['features/base/known-domains'];
32
-    const now = Date.now();
33 51
     const entryMap = new Map();
34 52
 
35 53
     for (const event of events) {
36 54
         const entry = _parseCalendarEntry(event, knownDomains);
37 55
 
38
-        if (entry && entry.endDate > now) {
56
+        if (entry && _isDisplayableCalendarEntry(entry)) {
39 57
             // As was stated above, we don't display subsequent occurrences of
40 58
             // recurring events, and the repetitions of events coming from
41 59
             // multiple calendars.
@@ -111,6 +129,8 @@ function _parseCalendarEntry(event, knownDomains) {
111 129
             );
112 130
         } else {
113 131
             return {
132
+                allDay: event.allDay,
133
+                attendees: event.attendees,
114 134
                 calendarId: event.calendarId,
115 135
                 endDate,
116 136
                 id: event.id,

Loading…
Откажи
Сачувај