소스 검색

Coding style: formatting, naming

master
Lyubo Marinov 7 년 전
부모
커밋
f1ab160c62

+ 31
- 11
react/features/calendar-sync/actionTypes.js 파일 보기

@@ -1,24 +1,44 @@
1 1
 // @flow
2 2
 
3 3
 /**
4
- * Action to signal that calendar access has already been requested
5
- * since the app started, so no new request should be done unless the
6
- * user explicitly tries to refresh the calendar view.
4
+ * Action to add a new domain to the list of domain known to the feature
5
+ * calendar-sync.
6
+ *
7
+ * {
8
+ *     type: ADD_KNOWN_DOMAIN,
9
+ *     knownDomain: string
10
+ * }
7 11
  */
8
-export const CALENDAR_ACCESS_REQUESTED = Symbol('CALENDAR_ACCESS_REQUESTED');
12
+export const ADD_KNOWN_DOMAIN = Symbol('ADD_KNOWN_DOMAIN');
9 13
 
10 14
 /**
11
- * Action to update the current calendar entry list in the store.
15
+ * Action to refresh (re-fetch) the entry list.
16
+ *
17
+ * {
18
+ *     type: REFRESH_CALENDAR,
19
+ *     forcePermission: boolean
20
+ * }
12 21
  */
13
-export const NEW_CALENDAR_ENTRY_LIST = Symbol('NEW_CALENDAR_ENTRY_LIST');
22
+export const REFRESH_CALENDAR = Symbol('REFRESH_CALENDAR');
14 23
 
15 24
 /**
16
- * Action to add a new known domain to the list.
25
+ * Action to signal that calendar access has already been requested since the
26
+ * app started, so no new request should be done unless the user explicitly
27
+ * tries to refresh the calendar view.
28
+ *
29
+ * {
30
+ *     type: SET_CALENDAR_AUTHORIZATION,
31
+ *     authorization: ?string
32
+ * }
17 33
  */
18
-export const NEW_KNOWN_DOMAIN = Symbol('NEW_KNOWN_DOMAIN');
34
+export const SET_CALENDAR_AUTHORIZATION = Symbol('SET_CALENDAR_AUTHORIZATION');
19 35
 
20 36
 /**
21
- * Action to refresh (re-fetch) the entry list.
37
+ * Action to update the current calendar entry list in the store.
38
+ *
39
+ * {
40
+ *     type: SET_CALENDAR_EVENTS,
41
+ *     events: Array<Object>
42
+ * }
22 43
  */
23
-export const REFRESH_CALENDAR_ENTRY_LIST
24
-    = Symbol('REFRESH_CALENDAR_ENTRY_LIST');
44
+export const SET_CALENDAR_EVENTS = Symbol('SET_CALENDAR_EVENTS');

+ 33
- 31
react/features/calendar-sync/actions.js 파일 보기

@@ -1,58 +1,60 @@
1 1
 // @flow
2
+
2 3
 import {
3
-    CALENDAR_ACCESS_REQUESTED,
4
-    NEW_CALENDAR_ENTRY_LIST,
5
-    NEW_KNOWN_DOMAIN,
6
-    REFRESH_CALENDAR_ENTRY_LIST
4
+    SET_CALENDAR_AUTHORIZATION,
5
+    SET_CALENDAR_EVENTS,
6
+    ADD_KNOWN_DOMAIN,
7
+    REFRESH_CALENDAR
7 8
 } from './actionTypes';
8 9
 
9 10
 /**
10
- * Sends an action to signal that a calendar access has been requested. For
11
- * more info see the {@link CALENDAR_ACCESS_REQUESTED}.
11
+ * Sends an action to add a new known domain if not present yet.
12 12
  *
13
- * @param {string | undefined} status - The result of the last calendar
14
- * access request.
13
+ * @param {string} knownDomain - The new domain.
15 14
  * @returns {{
16
- *   type: CALENDAR_ACCESS_REQUESTED
15
+ *     type: ADD_KNOWN_DOMAIN,
16
+ *     knownDomain: string
17 17
  * }}
18 18
  */
19
-export function updateCalendarAccessStatus(status: ?string) {
19
+export function addKnownDomain(knownDomain: string) {
20 20
     return {
21
-        status,
22
-        type: CALENDAR_ACCESS_REQUESTED
21
+        type: ADD_KNOWN_DOMAIN,
22
+        knownDomain
23 23
     };
24 24
 }
25 25
 
26 26
 /**
27
- * Sends an action to add a new known domain if not present yet.
27
+ * Sends an action to refresh the entry list (fetches new data).
28 28
  *
29
- * @param {string} domainName - The new domain.
29
+ * @param {boolean|undefined} forcePermission - Whether to force to re-ask for
30
+ * the permission or not.
30 31
  * @returns {{
31
- *   type: NEW_KNOWN_DOMAIN,
32
- *   domainName: string
32
+ *     type: REFRESH_CALENDAR,
33
+ *     forcePermission: boolean
33 34
  * }}
34 35
  */
35
-export function maybeAddNewKnownDomain(domainName: string) {
36
+export function refreshCalendar(forcePermission: boolean = false) {
36 37
     return {
37
-        type: NEW_KNOWN_DOMAIN,
38
-        domainName
38
+        type: REFRESH_CALENDAR,
39
+        forcePermission
39 40
     };
40 41
 }
41 42
 
42 43
 /**
43
- * Sends an action to refresh the entry list (fetches new data).
44
+ * Sends an action to signal that a calendar access has been requested. For more
45
+ * info, see {@link SET_CALENDAR_AUTHORIZATION}.
44 46
  *
45
- * @param {boolean|undefined} forcePermission - Whether to force to re-ask
46
- * for the permission or not.
47
+ * @param {string | undefined} authorization - The result of the last calendar
48
+ * authorization request.
47 49
  * @returns {{
48
- *   type: REFRESH_CALENDAR_ENTRY_LIST,
49
- *   forcePermission: boolean
50
+ *     type: SET_CALENDAR_AUTHORIZATION,
51
+ *     authorization: ?string
50 52
  * }}
51 53
  */
52
-export function refreshCalendarEntryList(forcePermission: boolean = false) {
54
+export function setCalendarAuthorization(authorization: ?string) {
53 55
     return {
54
-        forcePermission,
55
-        type: REFRESH_CALENDAR_ENTRY_LIST
56
+        type: SET_CALENDAR_AUTHORIZATION,
57
+        authorization
56 58
     };
57 59
 }
58 60
 
@@ -61,13 +63,13 @@ export function refreshCalendarEntryList(forcePermission: boolean = false) {
61 63
  *
62 64
  * @param {Array<Object>} events - The new list.
63 65
  * @returns {{
64
- *   type: NEW_CALENDAR_ENTRY_LIST,
65
- *   events: Array<Object>
66
+ *     type: SET_CALENDAR_EVENTS,
67
+ *     events: Array<Object>
66 68
  * }}
67 69
  */
68
-export function updateCalendarEntryList(events: Array<Object>) {
70
+export function setCalendarEvents(events: Array<Object>) {
69 71
     return {
70
-        type: NEW_CALENDAR_ENTRY_LIST,
72
+        type: SET_CALENDAR_EVENTS,
71 73
         events
72 74
     };
73 75
 }

+ 21
- 28
react/features/calendar-sync/components/ConferenceNotification.native.js 파일 보기

@@ -1,16 +1,13 @@
1 1
 // @flow
2
+
2 3
 import React, { Component } from 'react';
3
-import {
4
-    Text,
5
-    TouchableOpacity,
6
-    View
7
-} from 'react-native';
4
+import { Text, TouchableOpacity, View } from 'react-native';
8 5
 import { connect } from 'react-redux';
9 6
 
10 7
 import { appNavigate } from '../../app';
11 8
 import { getURLWithoutParamsNormalized } from '../../base/connection';
12
-import { getLocalizedDateFormatter, translate } from '../../base/i18n';
13 9
 import { Icon } from '../../base/font-icons';
10
+import { getLocalizedDateFormatter, translate } from '../../base/i18n';
14 11
 import { ASPECT_RATIO_NARROW } from '../../base/responsive-ui';
15 12
 
16 13
 import styles from './styles';
@@ -19,11 +16,6 @@ const ALERT_MILLISECONDS = 5 * 60 * 1000;
19 16
 
20 17
 type Props = {
21 18
 
22
-    /**
23
-     * The Redux dispatch function.
24
-     */
25
-    dispatch: Function,
26
-
27 19
     /**
28 20
      * The current aspect ratio of the screen.
29 21
      */
@@ -39,6 +31,11 @@ type Props = {
39 31
      */
40 32
     _eventList: Array<Object>,
41 33
 
34
+    /**
35
+     * The Redux dispatch function.
36
+     */
37
+    dispatch: Function,
38
+
42 39
     /**
43 40
      * The translate function.
44 41
      */
@@ -54,8 +51,8 @@ type State = {
54 51
 };
55 52
 
56 53
 /**
57
- * Component to display a permanent badge-like notification on the
58
- * conference screen when another meeting is about to start.
54
+ * Component to display a permanent badge-like notification on the conference
55
+ * screen when another meeting is about to start.
59 56
  */
60 57
 class ConferenceNotification extends Component<Props, State> {
61 58
     updateIntervalId: number;
@@ -103,7 +100,7 @@ class ConferenceNotification extends Component<Props, State> {
103 100
     }
104 101
 
105 102
     /**
106
-     * Implements the React Components's render method.
103
+     * Implements the React Components's render.
107 104
      *
108 105
      * @inheritdoc
109 106
      */
@@ -223,16 +220,14 @@ class ConferenceNotification extends Component<Props, State> {
223 220
             const now = Date.now();
224 221
 
225 222
             for (const event of _eventList) {
226
-                const eventUrl = getURLWithoutParamsNormalized(
227
-                    new URL(event.url)
228
-                );
223
+                const eventUrl
224
+                    = getURLWithoutParamsNormalized(new URL(event.url));
229 225
 
230 226
                 if (eventUrl !== _currentConferenceURL) {
231 227
                     if ((!eventToShow
232
-                        && event.startDate > now
233
-                        && event.startDate < now + ALERT_MILLISECONDS)
234
-                        || (event.startDate < now && event.endDate > now)
235
-                    ) {
228
+                                && event.startDate > now
229
+                                && event.startDate < now + ALERT_MILLISECONDS)
230
+                            || (event.startDate < now && event.endDate > now)) {
236 231
                         eventToShow = event;
237 232
                     }
238 233
                 }
@@ -249,8 +244,8 @@ class ConferenceNotification extends Component<Props, State> {
249 244
     /**
250 245
      * Opens the meeting URL that the notification shows.
251 246
      *
252
-     * @private
253 247
      * @param {string} url - The URL to open.
248
+     * @private
254 249
      * @returns {void}
255 250
      */
256 251
     _onGoToNext() {
@@ -260,7 +255,6 @@ class ConferenceNotification extends Component<Props, State> {
260 255
             this.props.dispatch(appNavigate(event.url));
261 256
         }
262 257
     }
263
-
264 258
 }
265 259
 
266 260
 /**
@@ -268,9 +262,9 @@ class ConferenceNotification extends Component<Props, State> {
268 262
  *
269 263
  * @param {Object} state - The redux state.
270 264
  * @returns {{
271
- *      _aspectRatio: Symbol,
272
- *      _currentConferenceURL: string,
273
- *      _eventList: Array
265
+ *     _aspectRatio: Symbol,
266
+ *     _currentConferenceURL: string,
267
+ *     _eventList: Array
274 268
  * }}
275 269
  */
276 270
 export function _mapStateToProps(state: Object) {
@@ -279,8 +273,7 @@ export function _mapStateToProps(state: Object) {
279 273
     return {
280 274
         _aspectRatio: state['features/base/responsive-ui'].aspectRatio,
281 275
         _currentConferenceURL:
282
-            locationURL
283
-                ? getURLWithoutParamsNormalized(locationURL) : '',
276
+            locationURL ? getURLWithoutParamsNormalized(locationURL) : '',
284 277
         _eventList: state['features/calendar-sync'].events
285 278
     };
286 279
 }

+ 29
- 36
react/features/calendar-sync/components/MeetingList.native.js 파일 보기

@@ -1,46 +1,46 @@
1 1
 // @flow
2
+
2 3
 import React, { Component } from 'react';
3 4
 import { Text, TouchableOpacity, View } from 'react-native';
4 5
 import { connect } from 'react-redux';
5 6
 
6
-import styles from './styles';
7
-
8
-import { refreshCalendarEntryList } from '../actions';
9
-
10 7
 import { appNavigate } from '../../app';
11 8
 import { getLocalizedDateFormatter, translate } from '../../base/i18n';
12 9
 import { NavigateSectionList } from '../../base/react';
13 10
 import { openSettings } from '../../mobile/permissions';
14 11
 
12
+import { refreshCalendar } from '../actions';
13
+import styles from './styles';
14
+
15 15
 type Props = {
16 16
 
17 17
     /**
18
-     * Indicates if the list is disabled or not.
18
+     * The current state of the calendar access permission.
19 19
      */
20
-    disabled: boolean,
20
+    _authorization: string,
21 21
 
22 22
     /**
23
-     * The Redux dispatch function.
23
+     * The calendar event list.
24 24
      */
25
-    dispatch: Function,
25
+    _eventList: Array<Object>,
26 26
 
27 27
     /**
28
-     * Tells the component if it's being displayed at the moment, or not.
29
-     * Note: as an example, on Android it can happen that the component
30
-     * is rendered but not displayed, because components like ViewPagerAndroid
31
-     * render their children even if they are not visible at the moment.
28
+     * Indicates if the list is disabled or not.
32 29
      */
33
-    displayed: boolean,
30
+    disabled: boolean,
34 31
 
35 32
     /**
36
-     * The current state of the calendar access permission.
33
+     * The Redux dispatch function.
37 34
      */
38
-    _calendarAccessStatus: string,
35
+    dispatch: Function,
39 36
 
40 37
     /**
41
-     * The calendar event list.
38
+     * Tells the component if it's being displayed at the moment, or not. Note:
39
+     * as an example, on Android it can happen that the component is rendered
40
+     * but not displayed, because components like ViewPagerAndroid render their
41
+     * children even if they are not visible at the moment.
42 42
      */
43
-    _eventList: Array<Object>,
43
+    displayed: boolean,
44 44
 
45 45
     /**
46 46
      * The translate function.
@@ -70,7 +70,7 @@ class MeetingList extends Component<Props> {
70 70
         const { dispatch, displayed } = props;
71 71
 
72 72
         if (displayed) {
73
-            dispatch(refreshCalendarEntryList());
73
+            dispatch(refreshCalendar());
74 74
         }
75 75
 
76 76
         this._getRenderListEmptyComponent
@@ -93,7 +93,7 @@ class MeetingList extends Component<Props> {
93 93
         if (newProps.displayed && !displayed) {
94 94
             const { dispatch } = this.props;
95 95
 
96
-            dispatch(refreshCalendarEntryList());
96
+            dispatch(refreshCalendar());
97 97
         }
98 98
     }
99 99
 
@@ -110,9 +110,7 @@ class MeetingList extends Component<Props> {
110 110
                 disabled = { disabled }
111 111
                 onPress = { this._onPress }
112 112
                 onRefresh = { this._onRefresh }
113
-                renderListEmptyComponent = {
114
-                    this._getRenderListEmptyComponent
115
-                }
113
+                renderListEmptyComponent = { this._getRenderListEmptyComponent }
116 114
                 sections = { this._toDisplayableList() } />
117 115
         );
118 116
     }
@@ -127,9 +125,9 @@ class MeetingList extends Component<Props> {
127 125
      * @returns {Component}
128 126
      */
129 127
     _getRenderListEmptyComponent() {
130
-        const { _calendarAccessStatus, t } = this.props;
128
+        const { _authorization, t } = this.props;
131 129
 
132
-        if (_calendarAccessStatus === 'denied') {
130
+        if (_authorization === 'denied') {
133 131
             return (
134 132
                 <View style = { styles.noPermissionMessageView }>
135 133
                     <Text style = { styles.noPermissionMessageText }>
@@ -159,9 +157,7 @@ class MeetingList extends Component<Props> {
159 157
      * @returns {void}
160 158
      */
161 159
     _onPress(url) {
162
-        const { dispatch } = this.props;
163
-
164
-        dispatch(appNavigate(url));
160
+        this.props.dispatch(appNavigate(url));
165 161
     }
166 162
 
167 163
     _onRefresh: () => void
@@ -173,9 +169,7 @@ class MeetingList extends Component<Props> {
173 169
      * @returns {void}
174 170
      */
175 171
     _onRefresh() {
176
-        const { dispatch } = this.props;
177
-
178
-        dispatch(refreshCalendarEntryList(true));
172
+        this.props.dispatch(refreshCalendar(true));
179 173
     }
180 174
 
181 175
     _toDisplayableItem: Object => Object
@@ -183,8 +177,8 @@ class MeetingList extends Component<Props> {
183 177
     /**
184 178
      * Creates a displayable object from an event.
185 179
      *
186
-     * @private
187 180
      * @param {Object} event - The calendar event.
181
+     * @private
188 182
      * @returns {Object}
189 183
      */
190 184
     _toDisplayableItem(event) {
@@ -202,8 +196,7 @@ class MeetingList extends Component<Props> {
202 196
     _toDisplayableList: () => Array<Object>
203 197
 
204 198
     /**
205
-     * Transforms the event list to a displayable list
206
-     * with sections.
199
+     * Transforms the event list to a displayable list with sections.
207 200
      *
208 201
      * @private
209 202
      * @returns {Array<Object>}
@@ -259,8 +252,8 @@ class MeetingList extends Component<Props> {
259 252
     /**
260 253
      * Generates a date (interval) string for a given event.
261 254
      *
262
-     * @private
263 255
      * @param {Object} event - The event.
256
+     * @private
264 257
      * @returns {string}
265 258
      */
266 259
     _toDateString(event) {
@@ -278,14 +271,14 @@ class MeetingList extends Component<Props> {
278 271
  *
279 272
  * @param {Object} state - The redux state.
280 273
  * @returns {{
281
- *      _eventList: Array
274
+ *     _eventList: Array
282 275
  * }}
283 276
  */
284 277
 export function _mapStateToProps(state: Object) {
285 278
     const calendarSyncState = state['features/calendar-sync'];
286 279
 
287 280
     return {
288
-        _calendarAccessStatus: calendarSyncState.calendarAccessStatus,
281
+        _authorization: calendarSyncState.authorization,
289 282
         _eventList: calendarSyncState.events
290 283
     };
291 284
 }

+ 1
- 1
react/features/calendar-sync/components/index.js 파일 보기

@@ -1,2 +1,2 @@
1
-export { default as MeetingList } from './MeetingList';
2 1
 export { default as ConferenceNotification } from './ConferenceNotification';
2
+export { default as MeetingList } from './MeetingList';

+ 93
- 105
react/features/calendar-sync/middleware.js 파일 보기

@@ -1,5 +1,5 @@
1 1
 // @flow
2
-import Logger from 'jitsi-meet-logger';
2
+
3 3
 import RNCalendarEvents from 'react-native-calendar-events';
4 4
 
5 5
 import { APP_WILL_MOUNT } from '../app';
@@ -8,18 +8,18 @@ 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
-
12 11
 import {
13
-    maybeAddNewKnownDomain,
14
-    updateCalendarAccessStatus,
15
-    updateCalendarEntryList
12
+    addKnownDomain,
13
+    setCalendarAuthorization,
14
+    setCalendarEvents
16 15
 } from './actions';
17
-import { REFRESH_CALENDAR_ENTRY_LIST } from './actionTypes';
16
+import { REFRESH_CALENDAR } from './actionTypes';
17
+
18
+const logger = require('jitsi-meet-logger').getLogger(__filename);
18 19
 
19 20
 const FETCH_END_DAYS = 10;
20 21
 const FETCH_START_DAYS = -1;
21 22
 const MAX_LIST_LENGTH = 10;
22
-const logger = Logger.getLogger(__filename);
23 23
 
24 24
 MiddlewareRegistry.register(store => next => action => {
25 25
     const result = next(action);
@@ -28,48 +28,48 @@ MiddlewareRegistry.register(store => next => action => {
28 28
     case APP_STATE_CHANGED:
29 29
         _maybeClearAccessStatus(store, action);
30 30
         break;
31
+
31 32
     case APP_WILL_MOUNT:
32 33
         _ensureDefaultServer(store);
33 34
         _fetchCalendarEntries(store, false, false);
34 35
         break;
35
-    case REFRESH_CALENDAR_ENTRY_LIST:
36
+
37
+    case REFRESH_CALENDAR:
36 38
         _fetchCalendarEntries(store, true, action.forcePermission);
37 39
         break;
40
+
38 41
     case SET_ROOM:
39
-        _parseAndAddDomain(store);
42
+        _parseAndAddKnownDomain(store);
43
+        break;
40 44
     }
41 45
 
42 46
     return result;
43 47
 });
44 48
 
45 49
 /**
46
- * Clears the calendar access status when the app comes back from
47
- * the background. This is needed as some users may never quit the
48
- * app, but puts it into the background and we need to try to request
49
- * for a permission as often as possible, but not annoyingly often.
50
+ * Clears the calendar access status when the app comes back from the
51
+ * background. This is needed as some users may never quit the app, but puts it
52
+ * into the background and we need to try to request for a permission as often
53
+ * as possible, but not annoyingly often.
50 54
  *
51
- * @private
52 55
  * @param {Object} store - The redux store.
53 56
  * @param {Object} action - The Redux action.
57
+ * @private
54 58
  * @returns {void}
55 59
  */
56
-function _maybeClearAccessStatus(store, action) {
57
-    const { appState } = action;
58
-
60
+function _maybeClearAccessStatus(store, { appState }) {
59 61
     if (appState === 'background') {
60
-        const { dispatch } = store;
61
-
62
-        dispatch(updateCalendarAccessStatus(undefined));
62
+        store.dispatch(setCalendarAuthorization(undefined));
63 63
     }
64 64
 }
65 65
 
66 66
 /**
67 67
  * Ensures calendar access if possible and resolves the promise if it's granted.
68 68
  *
69
- * @private
70 69
  * @param {boolean} promptForPermission - Flag to tell the app if it should
71 70
  * prompt for a calendar permission if it wasn't granted yet.
72 71
  * @param {Function} dispatch - The Redux dispatch function.
72
+ * @private
73 73
  * @returns {Promise}
74 74
  */
75 75
 function _ensureCalendarAccess(promptForPermission, dispatch) {
@@ -81,107 +81,96 @@ function _ensureCalendarAccess(promptForPermission, dispatch) {
81 81
                 } else if (promptForPermission) {
82 82
                     RNCalendarEvents.authorizeEventStore()
83 83
                         .then(result => {
84
-                            dispatch(updateCalendarAccessStatus(result));
84
+                            dispatch(setCalendarAuthorization(result));
85 85
                             resolve(result === 'authorized');
86 86
                         })
87
-                        .catch(error => {
88
-                            reject(error);
89
-                        });
87
+                        .catch(reject);
90 88
                 } else {
91 89
                     resolve(false);
92 90
                 }
93 91
             })
94
-            .catch(error => {
95
-                reject(error);
96
-            });
92
+            .catch(reject);
97 93
     });
98 94
 }
99 95
 
100 96
 /**
101 97
  * Ensures presence of the default server in the known domains list.
102 98
  *
103
- * @private
104 99
  * @param {Object} store - The redux store.
100
+ * @private
105 101
  * @returns {Promise}
106 102
  */
107
-function _ensureDefaultServer(store) {
108
-    const state = store.getState();
109
-    const defaultURL = parseURIString(
110
-        state['features/app'].app._getDefaultURL()
111
-    );
103
+function _ensureDefaultServer({ dispatch, getState }) {
104
+    const state = getState();
105
+    const defaultURL
106
+        = parseURIString(state['features/app'].app._getDefaultURL());
112 107
 
113
-    store.dispatch(maybeAddNewKnownDomain(defaultURL.host));
108
+    dispatch(addKnownDomain(defaultURL.host));
114 109
 }
115 110
 
116 111
 /**
117 112
  * Reads the user's calendar and updates the stored entries if need be.
118 113
  *
119
- * @private
120 114
  * @param {Object} store - The redux store.
121 115
  * @param {boolean} maybePromptForPermission - Flag to tell the app if it should
122 116
  * prompt for a calendar permission if it wasn't granted yet.
123
- * @param {boolean|undefined} forcePermission - Whether to force to re-ask
124
- * for the permission or not.
117
+ * @param {boolean|undefined} forcePermission - Whether to force to re-ask for
118
+ * the permission or not.
119
+ * @private
125 120
  * @returns {void}
126 121
  */
127 122
 function _fetchCalendarEntries(
128
-        store,
123
+        { dispatch, getState },
129 124
         maybePromptForPermission,
130
-        forcePermission
131
-) {
132
-    const { dispatch } = store;
133
-    const state = store.getState()['features/calendar-sync'];
134
-    const { calendarAccessStatus } = state;
125
+        forcePermission) {
126
+    const state = getState()['features/calendar-sync'];
135 127
     const promptForPermission
136
-        = (maybePromptForPermission && !calendarAccessStatus)
137
-        || forcePermission;
128
+        = (maybePromptForPermission && !state.authorization)
129
+            || forcePermission;
138 130
 
139 131
     _ensureCalendarAccess(promptForPermission, dispatch)
140
-    .then(accessGranted => {
141
-        if (accessGranted) {
142
-            const startDate = new Date();
143
-            const endDate = new Date();
144
-
145
-            startDate.setDate(startDate.getDate() + FETCH_START_DAYS);
146
-            endDate.setDate(endDate.getDate() + FETCH_END_DAYS);
147
-
148
-            RNCalendarEvents.fetchAllEvents(
149
-                startDate.getTime(),
150
-                endDate.getTime(),
151
-                []
152
-            )
153
-            .then(events => {
154
-                const { knownDomains } = state;
155
-
156
-                _updateCalendarEntries(events, knownDomains, dispatch);
157
-            })
158
-            .catch(error => {
159
-                logger.error('Error fetching calendar.', error);
160
-            });
161
-        } else {
162
-            logger.warn('Calendar access not granted.');
163
-        }
164
-    })
165
-    .catch(reason => {
166
-        logger.error('Error accessing calendar.', reason);
167
-    });
132
+        .then(accessGranted => {
133
+            if (accessGranted) {
134
+                const startDate = new Date();
135
+                const endDate = new Date();
136
+
137
+                startDate.setDate(startDate.getDate() + FETCH_START_DAYS);
138
+                endDate.setDate(endDate.getDate() + FETCH_END_DAYS);
139
+
140
+                RNCalendarEvents.fetchAllEvents(
141
+                        startDate.getTime(),
142
+                        endDate.getTime(),
143
+                        [])
144
+                    .then(events =>
145
+                        _updateCalendarEntries(
146
+                            events,
147
+                            state.knownDomains,
148
+                            dispatch))
149
+                    .catch(error =>
150
+                        logger.error('Error fetching calendar.', error));
151
+            } else {
152
+                logger.warn('Calendar access not granted.');
153
+            }
154
+        })
155
+        .catch(reason => {
156
+            logger.error('Error accessing calendar.', reason);
157
+        });
168 158
 }
169 159
 
170 160
 /**
171 161
  * Retreives a jitsi URL from an event if present.
172 162
  *
173
- * @private
174 163
  * @param {Object} event - The event to parse.
175 164
  * @param {Array<string>} knownDomains - The known domain names.
165
+ * @private
176 166
  * @returns {string}
177
- *
178 167
  */
179 168
 function _getURLFromEvent(event, knownDomains) {
180 169
     const linkTerminatorPattern = '[^\\s<>$]';
181
-    /* eslint-disable max-len */
182 170
     const urlRegExp
183
-        = new RegExp(`http(s)?://(${knownDomains.join('|')})/${linkTerminatorPattern}+`, 'gi');
184
-    /* eslint-enable max-len */
171
+        = new RegExp(
172
+            `http(s)?://(${knownDomains.join('|')})/${linkTerminatorPattern}+`,
173
+            'gi');
185 174
     const schemeRegExp
186 175
         = new RegExp(`${APP_LINK_SCHEME}${linkTerminatorPattern}+`, 'gi');
187 176
     const fieldsToSearch = [
@@ -191,16 +180,13 @@ function _getURLFromEvent(event, knownDomains) {
191 180
         event.notes,
192 181
         event.description
193 182
     ];
194
-    let matchArray;
195 183
 
196 184
     for (const field of fieldsToSearch) {
197 185
         if (typeof field === 'string') {
198
-            if (
199
-                (matchArray
200
-                    = urlRegExp.exec(field) || schemeRegExp.exec(field))
201
-                        !== null
202
-            ) {
203
-                return matchArray[0];
186
+            const matches = urlRegExp.exec(field) || schemeRegExp.exec(field);
187
+
188
+            if (matches) {
189
+                return matches[0];
204 190
             }
205 191
         }
206 192
     }
@@ -209,36 +195,36 @@ function _getURLFromEvent(event, knownDomains) {
209 195
 }
210 196
 
211 197
 /**
212
- * Retreives the domain name of a room upon join and stores it
213
- * in the known domain list, if not present yet.
198
+ * Retreives the domain name of a room upon join and stores it in the known
199
+ * domain list, if not present yet.
214 200
  *
215
- * @private
216 201
  * @param {Object} store - The redux store.
202
+ * @private
217 203
  * @returns {Promise}
218 204
  */
219
-function _parseAndAddDomain(store) {
220
-    const { locationURL } = store.getState()['features/base/connection'];
205
+function _parseAndAddKnownDomain({ dispatch, getState }) {
206
+    const { locationURL } = getState()['features/base/connection'];
221 207
 
222
-    store.dispatch(maybeAddNewKnownDomain(locationURL.host));
208
+    dispatch(addKnownDomain(locationURL.host));
223 209
 }
224 210
 
225 211
 /**
226 212
  * Updates the calendar entries in Redux when new list is received.
227 213
  *
228
- * @private
229 214
  * @param {Object} event - An event returned from the native calendar.
230 215
  * @param {Array<string>} knownDomains - The known domain list.
216
+ * @private
231 217
  * @returns {CalendarEntry}
232 218
  */
233 219
 function _parseCalendarEntry(event, knownDomains) {
234 220
     if (event) {
235
-        const jitsiURL = _getURLFromEvent(event, knownDomains);
221
+        const url = _getURLFromEvent(event, knownDomains);
236 222
 
237
-        if (jitsiURL) {
238
-            const eventStartDate = Date.parse(event.startDate);
239
-            const eventEndDate = Date.parse(event.endDate);
223
+        if (url) {
224
+            const startDate = Date.parse(event.startDate);
225
+            const endDate = Date.parse(event.endDate);
240 226
 
241
-            if (isNaN(eventStartDate) || isNaN(eventEndDate)) {
227
+            if (isNaN(startDate) || isNaN(endDate)) {
242 228
                 logger.warn(
243 229
                     'Skipping invalid calendar event',
244 230
                     event.title,
@@ -247,11 +233,11 @@ function _parseCalendarEntry(event, knownDomains) {
247 233
                 );
248 234
             } else {
249 235
                 return {
250
-                    endDate: eventEndDate,
236
+                    endDate,
251 237
                     id: event.id,
252
-                    startDate: eventStartDate,
238
+                    startDate,
253 239
                     title: event.title,
254
-                    url: jitsiURL
240
+                    url
255 241
                 };
256 242
             }
257 243
         }
@@ -263,10 +249,10 @@ function _parseCalendarEntry(event, knownDomains) {
263 249
 /**
264 250
  * Updates the calendar entries in Redux when new list is received.
265 251
  *
266
- * @private
267 252
  * @param {Array<CalendarEntry>} events - The new event list.
268 253
  * @param {Array<string>} knownDomains - The known domain list.
269 254
  * @param {Function} dispatch - The Redux dispatch function.
255
+ * @private
270 256
  * @returns {void}
271 257
  */
272 258
 function _updateCalendarEntries(events, knownDomains, dispatch) {
@@ -283,8 +269,10 @@ function _updateCalendarEntries(events, knownDomains, dispatch) {
283 269
             }
284 270
         }
285 271
 
286
-        dispatch(updateCalendarEntryList(eventList.sort((a, b) =>
287
-            a.startDate - b.startDate
288
-        ).slice(0, MAX_LIST_LENGTH)));
272
+        dispatch(
273
+            setCalendarEvents(
274
+                eventList
275
+                    .sort((a, b) => a.startDate - b.startDate)
276
+                    .slice(0, MAX_LIST_LENGTH)));
289 277
     }
290 278
 }

+ 46
- 38
react/features/calendar-sync/reducer.js 파일 보기

@@ -4,18 +4,18 @@ import { ReducerRegistry } from '../base/redux';
4 4
 import { PersistenceRegistry } from '../base/storage';
5 5
 
6 6
 import {
7
-    CALENDAR_ACCESS_REQUESTED,
8
-    NEW_CALENDAR_ENTRY_LIST,
9
-    NEW_KNOWN_DOMAIN
7
+    ADD_KNOWN_DOMAIN,
8
+    SET_CALENDAR_AUTHORIZATION,
9
+    SET_CALENDAR_EVENTS
10 10
 } from './actionTypes';
11 11
 
12 12
 const DEFAULT_STATE = {
13 13
     /**
14 14
      * Note: If features/calendar-sync ever gets persisted, do not persist the
15
-     * calendarAccessStatus value as it's needed to remain a runtime value to
16
-     * see if we need to re-request the calendar permission from the user.
15
+     * authorization value as it's needed to remain a runtime value to see if we
16
+     * need to re-request the calendar permission from the user.
17 17
      */
18
-    calendarAccessStatus: undefined,
18
+    authorization: undefined,
19 19
     events: [],
20 20
     knownDomains: []
21 21
 };
@@ -28,54 +28,62 @@ PersistenceRegistry.register(STORE_NAME, {
28 28
     knownDomains: true
29 29
 });
30 30
 
31
-ReducerRegistry.register(
32
-    STORE_NAME,
33
-    (state = DEFAULT_STATE, action) => {
34
-        switch (action.type) {
35
-        case CALENDAR_ACCESS_REQUESTED:
36
-            return {
37
-                ...state,
38
-                calendarAccessStatus: action.status
39
-            };
31
+ReducerRegistry.register(STORE_NAME, (state = DEFAULT_STATE, action) => {
32
+    switch (action.type) {
33
+    case ADD_KNOWN_DOMAIN:
34
+        return _addKnownDomain(state, action);
40 35
 
41
-        case NEW_CALENDAR_ENTRY_LIST:
42
-            return {
43
-                ...state,
44
-                events: action.events
45
-            };
36
+    case SET_CALENDAR_AUTHORIZATION:
37
+        return {
38
+            ...state,
39
+            authorization: action.status
40
+        };
46 41
 
47
-        case NEW_KNOWN_DOMAIN:
48
-            return _maybeAddNewDomain(state, action);
42
+    case SET_CALENDAR_EVENTS:
43
+        return {
44
+            ...state,
45
+            events: action.events
46
+        };
49 47
 
50
-        default:
51
-            return state;
52
-        }
53
-    });
48
+    default:
49
+        return state;
50
+    }
51
+});
54 52
 
55 53
 /**
56 54
  * Adds a new domain to the known domain list if not present yet.
57 55
  *
58
- * @private
59 56
  * @param {Object} state - The redux state.
60 57
  * @param {Object} action - The redux action.
58
+ * @private
61 59
  * @returns {Object}
62 60
  */
63
-function _maybeAddNewDomain(state, action) {
64
-    let { domainName } = action;
65
-    const { knownDomains } = state;
61
+function _addKnownDomain(state, action) {
62
+    let { knownDomain } = action;
63
+
64
+    if (knownDomain) {
65
+        knownDomain = knownDomain.toLowerCase();
66
+
67
+        let { knownDomains } = state;
66 68
 
67
-    if (domainName && domainName.length) {
68
-        domainName = domainName.toLowerCase();
69
-        if (knownDomains.indexOf(domainName) === -1) {
70
-            knownDomains.push(domainName);
69
+        if (knownDomains.indexOf(knownDomain) === -1) {
70
+            // Add the specified known domain and at the same time avoid
71
+            // modifying the knownDomains Array instance referenced by the
72
+            // current redux state.
73
+            knownDomains = [
74
+                ...state.knownDomains,
75
+                knownDomain
76
+            ];
71 77
 
72 78
             // Ensure the list doesn't exceed a/the maximum size.
73 79
             knownDomains.splice(0, knownDomains.length - MAX_DOMAIN_LIST_SIZE);
80
+
81
+            return {
82
+                ...state,
83
+                knownDomains
84
+            };
74 85
         }
75 86
     }
76 87
 
77
-    return {
78
-        ...state,
79
-        knownDomains
80
-    };
88
+    return state;
81 89
 }

+ 7
- 3
react/features/mobile/callkit/middleware.js 파일 보기

@@ -1,13 +1,17 @@
1 1
 // @flow
2 2
 
3
-import { NativeModules } from 'react-native';
4 3
 import uuid from 'uuid';
5 4
 
6 5
 import {
7 6
     createTrackMutedEvent,
8 7
     sendAnalytics
9 8
 } from '../../analytics';
10
-import { APP_WILL_MOUNT, APP_WILL_UNMOUNT, appNavigate } from '../../app';
9
+import {
10
+    APP_WILL_MOUNT,
11
+    APP_WILL_UNMOUNT,
12
+    appNavigate,
13
+    getName
14
+} from '../../app';
11 15
 import {
12 16
     CONFERENCE_FAILED,
13 17
     CONFERENCE_LEFT,
@@ -97,7 +101,7 @@ function _appWillMount({ dispatch, getState }, next, action) {
97 101
 
98 102
     CallKit.setProviderConfiguration({
99 103
         iconTemplateImageName: 'CallKitIcon',
100
-        localizedName: NativeModules.AppInfo.name
104
+        localizedName: getName()
101 105
     });
102 106
 
103 107
     const context = {

+ 4
- 3
react/features/share-room/middleware.js 파일 보기

@@ -1,7 +1,8 @@
1
-/* @flow */
1
+// @flow
2 2
 
3
-import { NativeModules, Share } from 'react-native';
3
+import { Share } from 'react-native';
4 4
 
5
+import { getName } from '../app';
5 6
 import { MiddlewareRegistry } from '../base/redux';
6 7
 
7 8
 import { endShareRoom } from './actions';
@@ -37,7 +38,7 @@ function _shareRoom(roomURL: string, dispatch: Function) {
37 38
     // review before i18n was introduces in react/. However, I reviewed it
38 39
     // afterwards. Translate the display/human-readable strings.
39 40
     const message = `Click the following link to join the meeting: ${roomURL}`;
40
-    const title = `${NativeModules.AppInfo.name} Conference`;
41
+    const title = `${getName()} Conference`;
41 42
     const onFulfilled
42 43
         = (shared: boolean) => dispatch(endShareRoom(roomURL, shared));
43 44
 

+ 4
- 4
react/features/welcome/components/PagedList.ios.js 파일 보기

@@ -5,7 +5,7 @@ import { View, TabBarIOS } from 'react-native';
5 5
 import { connect } from 'react-redux';
6 6
 
7 7
 import { translate } from '../../base/i18n';
8
-import { MeetingList, refreshCalendarEntryList } from '../../calendar-sync';
8
+import { MeetingList, refreshCalendar } from '../../calendar-sync';
9 9
 import { RecentList } from '../../recent-list';
10 10
 
11 11
 import AbstractPagedList from './AbstractPagedList';
@@ -85,10 +85,10 @@ class PagedList extends AbstractPagedList {
85 85
             if (tabIndex === 1) {
86 86
                 /**
87 87
                  * This is a workaround as TabBarIOS doesn't invoke
88
-                 * componentWillReciveProps on prop change of the
89
-                 * MeetingList component.
88
+                 * componentWillReciveProps on prop change of the MeetingList
89
+                 * component.
90 90
                  */
91
-                this.props.dispatch(refreshCalendarEntryList());
91
+                this.props.dispatch(refreshCalendar());
92 92
             }
93 93
         };
94 94
     }

Loading…
취소
저장