|
@@ -3,13 +3,12 @@
|
3
|
3
|
import RNCalendarEvents from 'react-native-calendar-events';
|
4
|
4
|
|
5
|
5
|
import { APP_WILL_MOUNT } from '../app';
|
6
|
|
-import { SET_ROOM } from '../base/conference';
|
|
6
|
+import { ADD_KNOWN_DOMAINS } from '../base/domains';
|
7
|
7
|
import { MiddlewareRegistry } from '../base/redux';
|
8
|
8
|
import { APP_LINK_SCHEME, parseURIString } from '../base/util';
|
9
|
9
|
import { APP_STATE_CHANGED } from '../mobile/background';
|
10
|
10
|
|
11
|
11
|
import {
|
12
|
|
- addKnownDomain,
|
13
|
12
|
setCalendarAuthorization,
|
14
|
13
|
setCalendarEvents
|
15
|
14
|
} from './actions';
|
|
@@ -18,8 +17,19 @@ import { CALENDAR_ENABLED } from './constants';
|
18
|
17
|
|
19
|
18
|
const logger = require('jitsi-meet-logger').getLogger(__filename);
|
20
|
19
|
|
|
20
|
+/**
|
|
21
|
+ * The no. of days to fetch.
|
|
22
|
+ */
|
21
|
23
|
const FETCH_END_DAYS = 10;
|
|
24
|
+
|
|
25
|
+/**
|
|
26
|
+ * The no. of days to go back when fetching.
|
|
27
|
+ */
|
22
|
28
|
const FETCH_START_DAYS = -1;
|
|
29
|
+
|
|
30
|
+/**
|
|
31
|
+ * The max number of events to fetch from the calendar.
|
|
32
|
+ */
|
23
|
33
|
const MAX_LIST_LENGTH = 10;
|
24
|
34
|
|
25
|
35
|
CALENDAR_ENABLED
|
|
@@ -31,18 +41,14 @@ CALENDAR_ENABLED
|
31
|
41
|
_maybeClearAccessStatus(store, action);
|
32
|
42
|
break;
|
33
|
43
|
|
|
44
|
+ case ADD_KNOWN_DOMAINS:
|
34
|
45
|
case APP_WILL_MOUNT:
|
35
|
|
- _ensureDefaultServer(store);
|
36
|
46
|
_fetchCalendarEntries(store, false, false);
|
37
|
47
|
break;
|
38
|
48
|
|
39
|
49
|
case REFRESH_CALENDAR:
|
40
|
50
|
_fetchCalendarEntries(store, true, action.forcePermission);
|
41
|
51
|
break;
|
42
|
|
-
|
43
|
|
- case SET_ROOM:
|
44
|
|
- _parseAndAddKnownDomain(store);
|
45
|
|
- break;
|
46
|
52
|
}
|
47
|
53
|
|
48
|
54
|
return result;
|
|
@@ -95,20 +101,6 @@ function _ensureCalendarAccess(promptForPermission, dispatch) {
|
95
|
101
|
});
|
96
|
102
|
}
|
97
|
103
|
|
98
|
|
-/**
|
99
|
|
- * Ensures presence of the default server in the known domains list.
|
100
|
|
- *
|
101
|
|
- * @param {Object} store - The redux store.
|
102
|
|
- * @private
|
103
|
|
- * @returns {Promise}
|
104
|
|
- */
|
105
|
|
-function _ensureDefaultServer({ dispatch, getState }) {
|
106
|
|
- const defaultURL
|
107
|
|
- = parseURIString(getState()['features/app'].app._getDefaultURL());
|
108
|
|
-
|
109
|
|
- dispatch(addKnownDomain(defaultURL.host));
|
110
|
|
-}
|
111
|
|
-
|
112
|
104
|
/**
|
113
|
105
|
* Reads the user's calendar and updates the stored entries if need be.
|
114
|
106
|
*
|
|
@@ -124,9 +116,10 @@ function _fetchCalendarEntries(
|
124
|
116
|
{ dispatch, getState },
|
125
|
117
|
maybePromptForPermission,
|
126
|
118
|
forcePermission) {
|
127
|
|
- const state = getState()['features/calendar-sync'];
|
|
119
|
+ const featureState = getState()['features/calendar-sync'];
|
|
120
|
+ const knownDomains = getState()['features/base/domains'];
|
128
|
121
|
const promptForPermission
|
129
|
|
- = (maybePromptForPermission && !state.authorization)
|
|
122
|
+ = (maybePromptForPermission && !featureState.authorization)
|
130
|
123
|
|| forcePermission;
|
131
|
124
|
|
132
|
125
|
_ensureCalendarAccess(promptForPermission, dispatch)
|
|
@@ -145,7 +138,7 @@ function _fetchCalendarEntries(
|
145
|
138
|
.then(events =>
|
146
|
139
|
_updateCalendarEntries(
|
147
|
140
|
events,
|
148
|
|
- state.knownDomains,
|
|
141
|
+ knownDomains,
|
149
|
142
|
dispatch))
|
150
|
143
|
.catch(error =>
|
151
|
144
|
logger.error('Error fetching calendar.', error));
|
|
@@ -199,20 +192,6 @@ function _getURLFromEvent(event, knownDomains) {
|
199
|
192
|
return null;
|
200
|
193
|
}
|
201
|
194
|
|
202
|
|
-/**
|
203
|
|
- * Retrieves the domain name of a room upon join and stores it in the known
|
204
|
|
- * domain list, if not present yet.
|
205
|
|
- *
|
206
|
|
- * @param {Object} store - The redux store.
|
207
|
|
- * @private
|
208
|
|
- * @returns {Promise}
|
209
|
|
- */
|
210
|
|
-function _parseAndAddKnownDomain({ dispatch, getState }) {
|
211
|
|
- const { locationURL } = getState()['features/base/connection'];
|
212
|
|
-
|
213
|
|
- dispatch(addKnownDomain(locationURL.host));
|
214
|
|
-}
|
215
|
|
-
|
216
|
195
|
/**
|
217
|
196
|
* Updates the calendar entries in Redux when new list is received.
|
218
|
197
|
*
|