소스 검색

Coding style: formatting, typos

master
Lyubo Marinov 7 년 전
부모
커밋
13e0e18f37

+ 60
- 59
react/features/base/react/components/native/NavigateSectionList.js 파일 보기

1
 // @flow
1
 // @flow
2
+
2
 import React, { Component } from 'react';
3
 import React, { Component } from 'react';
3
 import {
4
 import {
4
     SafeAreaView,
5
     SafeAreaView,
8
     View
9
     View
9
 } from 'react-native';
10
 } from 'react-native';
10
 
11
 
11
-import styles, { UNDERLAY_COLOR } from './styles';
12
-
12
+import { Icon } from '../../../font-icons';
13
 import { translate } from '../../../i18n';
13
 import { translate } from '../../../i18n';
14
 
14
 
15
-import { Icon } from '../../../font-icons';
15
+import styles, { UNDERLAY_COLOR } from './styles';
16
 
16
 
17
 type Props = {
17
 type Props = {
18
 
18
 
60
      * ]
60
      * ]
61
      */
61
      */
62
     sections: Array<Object>
62
     sections: Array<Object>
63
-}
63
+};
64
 
64
 
65
 /**
65
 /**
66
- * Implements a general section list to display items that have a URL
67
- * property and navigates to (probably) meetings, such as the recent list
68
- * or the meeting list components.
66
+ * Implements a general section list to display items that have a URL property
67
+ * and navigates to (probably) meetings, such as the recent list or the meeting
68
+ * list components.
69
  */
69
  */
70
 class NavigateSectionList extends Component<Props> {
70
 class NavigateSectionList extends Component<Props> {
71
+    /**
72
+     * Creates an empty section object.
73
+     *
74
+     * @param {string} title - The title of the section.
75
+     * @param {string} key - The key of the section. It must be unique.
76
+     * @private
77
+     * @returns {Object}
78
+     */
79
+    static createSection(title, key) {
80
+        return {
81
+            data: [],
82
+            key,
83
+            title
84
+        };
85
+    }
86
+
71
     /**
87
     /**
72
      * Constructor of the NavigateSectionList component.
88
      * Constructor of the NavigateSectionList component.
73
      *
89
      *
89
     }
105
     }
90
 
106
 
91
     /**
107
     /**
92
-     * Implements React's Component.render function.
108
+     * Implements React's Component.render.
93
      * Note: we don't use the refreshing value yet, because refreshing of these
109
      * Note: we don't use the refreshing value yet, because refreshing of these
94
      * lists is super quick, no need to complicate the code - yet.
110
      * lists is super quick, no need to complicate the code - yet.
95
      *
111
      *
96
      * @inheritdoc
112
      * @inheritdoc
97
      */
113
      */
98
     render() {
114
     render() {
99
-        const { renderListEmptyComponent, sections } = this.props;
115
+        const {
116
+            renderListEmptyComponent = this._renderListEmptyComponent,
117
+            sections
118
+        } = this.props;
100
 
119
 
101
         return (
120
         return (
102
             <SafeAreaView
121
             <SafeAreaView
103
                 style = { styles.container } >
122
                 style = { styles.container } >
104
                 <SectionList
123
                 <SectionList
105
-                    ListEmptyComponent = {
106
-                        renderListEmptyComponent
107
-                        || this._renderListEmptyComponent
108
-                    }
124
+                    ListEmptyComponent = { renderListEmptyComponent }
109
                     keyExtractor = { this._getItemKey }
125
                     keyExtractor = { this._getItemKey }
110
                     onRefresh = { this._onRefresh }
126
                     onRefresh = { this._onRefresh }
111
                     refreshing = { false }
127
                     refreshing = { false }
117
         );
133
         );
118
     }
134
     }
119
 
135
 
120
-    /**
121
-     * Creates an empty section object.
122
-     *
123
-     * @private
124
-     * @param {string} title - The title of the section.
125
-     * @param {string} key - The key of the section. It must be unique.
126
-     * @returns {Object}
127
-     */
128
-    static createSection(title, key) {
129
-        return {
130
-            data: [],
131
-            key,
132
-            title
133
-        };
134
-    }
135
-
136
-    _getAvatarColor: string => Object
136
+    _getAvatarColor: string => Object;
137
 
137
 
138
     /**
138
     /**
139
-     * Returns a style (color) based on the string that determines the
140
-     * color of the avatar.
139
+     * Returns a style (color) based on the string that determines the color of
140
+     * the avatar.
141
      *
141
      *
142
      * @param {string} colorBase - The string that is the base of the color.
142
      * @param {string} colorBase - The string that is the base of the color.
143
      * @private
143
      * @private
162
     /**
162
     /**
163
      * Generates a unique id to every item.
163
      * Generates a unique id to every item.
164
      *
164
      *
165
-     * @private
166
      * @param {Object} item - The item.
165
      * @param {Object} item - The item.
167
      * @param {number} index - The item index.
166
      * @param {number} index - The item index.
167
+     * @private
168
      * @returns {string}
168
      * @returns {string}
169
      */
169
      */
170
     _getItemKey(item, index) {
170
     _getItemKey(item, index) {
171
         return `${index}-${item.key}`;
171
         return `${index}-${item.key}`;
172
     }
172
     }
173
 
173
 
174
-    _onPress: string => Function
174
+    _onPress: string => Function;
175
 
175
 
176
     /**
176
     /**
177
      * Returns a function that is used in the onPress callback of the items.
177
      * Returns a function that is used in the onPress callback of the items.
178
      *
178
      *
179
-     * @private
180
      * @param {string} url - The URL of the item to navigate to.
179
      * @param {string} url - The URL of the item to navigate to.
180
+     * @private
181
      * @returns {Function}
181
      * @returns {Function}
182
      */
182
      */
183
     _onPress(url) {
183
     _onPress(url) {
188
         };
188
         };
189
     }
189
     }
190
 
190
 
191
-    _onRefresh: () => void
191
+    _onRefresh: () => void;
192
 
192
 
193
     /**
193
     /**
194
      * Invokes the onRefresh callback if present.
194
      * Invokes the onRefresh callback if present.
209
     /**
209
     /**
210
      * Renders a single item in the list.
210
      * Renders a single item in the list.
211
      *
211
      *
212
-     * @private
213
      * @param {Object} listItem - The item to render.
212
      * @param {Object} listItem - The item to render.
213
+     * @private
214
      * @returns {Component}
214
      * @returns {Component}
215
      */
215
      */
216
     _renderItem(listItem) {
216
     _renderItem(listItem) {
217
-        const { item } = listItem;
217
+        const { item: { colorBase, lines, title, url } } = listItem;
218
+
219
+        // XXX The value of title cannot be undefined; otherwise, react-native
220
+        // will throw a TypeError: Cannot read property of undefined. While it's
221
+        // difficult to get an undefined title and very likely requires the
222
+        // execution of incorrect source code, it is undesirable to break the
223
+        // whole app because of an undefined string.
224
+        if (typeof title === 'undefined') {
225
+            return null;
226
+        }
218
 
227
 
219
         return (
228
         return (
220
             <TouchableHighlight
229
             <TouchableHighlight
221
-                onPress = { this._onPress(item.url) }
230
+                onPress = { this._onPress(url) }
222
                 underlayColor = { UNDERLAY_COLOR }>
231
                 underlayColor = { UNDERLAY_COLOR }>
223
                 <View style = { styles.listItem }>
232
                 <View style = { styles.listItem }>
224
                     <View style = { styles.avatarContainer } >
233
                     <View style = { styles.avatarContainer } >
225
                         <View
234
                         <View
226
                             style = { [
235
                             style = { [
227
                                 styles.avatar,
236
                                 styles.avatar,
228
-                                this._getAvatarColor(item.colorBase)
237
+                                this._getAvatarColor(colorBase)
229
                             ] } >
238
                             ] } >
230
                             <Text style = { styles.avatarContent }>
239
                             <Text style = { styles.avatarContent }>
231
-                                { item.title.substr(0, 1).toUpperCase() }
240
+                                { title.substr(0, 1).toUpperCase() }
232
                             </Text>
241
                             </Text>
233
                         </View>
242
                         </View>
234
                     </View>
243
                     </View>
239
                                 styles.listItemText,
248
                                 styles.listItemText,
240
                                 styles.listItemTitle
249
                                 styles.listItemTitle
241
                             ] }>
250
                             ] }>
242
-                            { item.title }
251
+                            { title }
243
                         </Text>
252
                         </Text>
244
-                        {
245
-                            this._renderItemLines(item.lines)
246
-                        }
253
+                        { this._renderItemLines(lines) }
247
                     </View>
254
                     </View>
248
                 </View>
255
                 </View>
249
             </TouchableHighlight>
256
             </TouchableHighlight>
255
     /**
262
     /**
256
      * Renders a single line from the additional lines.
263
      * Renders a single line from the additional lines.
257
      *
264
      *
258
-     * @private
259
      * @param {string} line - The line text.
265
      * @param {string} line - The line text.
260
      * @param {number} index - The index of the line.
266
      * @param {number} index - The index of the line.
267
+     * @private
261
      * @returns {React$Node}
268
      * @returns {React$Node}
262
      */
269
      */
263
     _renderItemLine(line, index) {
270
     _renderItemLine(line, index) {
275
         );
282
         );
276
     }
283
     }
277
 
284
 
278
-    _renderItemLines: (Array<string>) => Array<React$Node>;
285
+    _renderItemLines: Array<string> => Array<React$Node>;
279
 
286
 
280
     /**
287
     /**
281
      * Renders the additional item lines, if any.
288
      * Renders the additional item lines, if any.
282
      *
289
      *
283
-     * @private
284
      * @param {Array<string>} lines - The lines to render.
290
      * @param {Array<string>} lines - The lines to render.
291
+     * @private
285
      * @returns {Array<React$Node>}
292
      * @returns {Array<React$Node>}
286
      */
293
      */
287
     _renderItemLines(lines) {
294
     _renderItemLines(lines) {
288
-        if (lines && lines.length) {
289
-            return lines.map((line, index) =>
290
-                this._renderItemLine(line, index)
291
-            );
292
-        }
293
-
294
-        return null;
295
+        return lines && lines.length ? lines.map(this._renderItemLine) : null;
295
     }
296
     }
296
 
297
 
297
-    _renderListEmptyComponent: () => Object
298
+    _renderListEmptyComponent: () => Object;
298
 
299
 
299
     /**
300
     /**
300
      * Renders a component to display when the list is empty.
301
      * Renders a component to display when the list is empty.
301
      *
302
      *
302
-     * @private
303
      * @param {Object} section - The section being rendered.
303
      * @param {Object} section - The section being rendered.
304
+     * @private
304
      * @returns {React$Node}
305
      * @returns {React$Node}
305
      */
306
      */
306
     _renderListEmptyComponent() {
307
     _renderListEmptyComponent() {
322
         return null;
323
         return null;
323
     }
324
     }
324
 
325
 
325
-    _renderSection: Object => Object
326
+    _renderSection: Object => Object;
326
 
327
 
327
     /**
328
     /**
328
      * Renders a section title.
329
      * Renders a section title.
329
      *
330
      *
330
-     * @private
331
      * @param {Object} section - The section being rendered.
331
      * @param {Object} section - The section being rendered.
332
+     * @private
332
      * @returns {React$Node}
333
      * @returns {React$Node}
333
      */
334
      */
334
     _renderSection(section) {
335
     _renderSection(section) {

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

83
     }
83
     }
84
 
84
 
85
     /**
85
     /**
86
-     * Implements React Component's componentWillReceiveProps function.
86
+     * Implements React Component's componentWillReceiveProps.
87
      *
87
      *
88
      * @inheritdoc
88
      * @inheritdoc
89
      */
89
      */
98
     }
98
     }
99
 
99
 
100
     /**
100
     /**
101
-     * Implements the React Components's render method.
101
+     * Implements the React Components's render.
102
      *
102
      *
103
      * @inheritdoc
103
      * @inheritdoc
104
      */
104
      */
115
         );
115
         );
116
     }
116
     }
117
 
117
 
118
-    _getRenderListEmptyComponent: () => Object
118
+    _getRenderListEmptyComponent: () => Object;
119
 
119
 
120
     /**
120
     /**
121
      * Returns a list empty component if a custom one has to be rendered instead
121
      * Returns a list empty component if a custom one has to be rendered instead
147
         return null;
147
         return null;
148
     }
148
     }
149
 
149
 
150
-    _onPress: string => Function
150
+    _onPress: string => Function;
151
 
151
 
152
     /**
152
     /**
153
      * Handles the list's navigate action.
153
      * Handles the list's navigate action.
160
         this.props.dispatch(appNavigate(url));
160
         this.props.dispatch(appNavigate(url));
161
     }
161
     }
162
 
162
 
163
-    _onRefresh: () => void
163
+    _onRefresh: () => void;
164
 
164
 
165
     /**
165
     /**
166
      * Callback to execute when the list is doing a pull-to-refresh.
166
      * Callback to execute when the list is doing a pull-to-refresh.
172
         this.props.dispatch(refreshCalendar(true));
172
         this.props.dispatch(refreshCalendar(true));
173
     }
173
     }
174
 
174
 
175
-    _toDisplayableItem: Object => Object
175
+    _toDisplayableItem: Object => Object;
176
 
176
 
177
     /**
177
     /**
178
      * Creates a displayable object from an event.
178
      * Creates a displayable object from an event.
193
         };
193
         };
194
     }
194
     }
195
 
195
 
196
-    _toDisplayableList: () => Array<Object>
196
+    _toDisplayableList: () => Array<Object>;
197
 
197
 
198
     /**
198
     /**
199
      * Transforms the event list to a displayable list with sections.
199
      * Transforms the event list to a displayable list with sections.
204
     _toDisplayableList() {
204
     _toDisplayableList() {
205
         const { _eventList, t } = this.props;
205
         const { _eventList, t } = this.props;
206
         const now = Date.now();
206
         const now = Date.now();
207
-        const nowSection = NavigateSectionList.createSection(
208
-            t('calendarSync.now'),
209
-            'now'
210
-        );
211
-        const nextSection = NavigateSectionList.createSection(
212
-            t('calendarSync.next'),
213
-            'next'
214
-        );
215
-        const laterSection = NavigateSectionList.createSection(
216
-            t('calendarSync.later'),
217
-            'later'
218
-        );
207
+        const { createSection } = NavigateSectionList;
208
+        const nowSection = createSection(t('calendarSync.now'), 'now');
209
+        const nextSection = createSection(t('calendarSync.next'), 'next');
210
+        const laterSection = createSection(t('calendarSync.later'), 'later');
219
 
211
 
220
         for (const event of _eventList) {
212
         for (const event of _eventList) {
221
             const displayableEvent = this._toDisplayableItem(event);
213
             const displayableEvent = this._toDisplayableItem(event);
224
                 nowSection.data.push(displayableEvent);
216
                 nowSection.data.push(displayableEvent);
225
             } else if (event.startDate > now) {
217
             } else if (event.startDate > now) {
226
                 if (nextSection.data.length
218
                 if (nextSection.data.length
227
-                && nextSection.data[0].startDate !== event.startDate) {
219
+                        && nextSection.data[0].startDate !== event.startDate) {
228
                     laterSection.data.push(displayableEvent);
220
                     laterSection.data.push(displayableEvent);
229
                 } else {
221
                 } else {
230
                     nextSection.data.push(displayableEvent);
222
                     nextSection.data.push(displayableEvent);
247
         return sectionList;
239
         return sectionList;
248
     }
240
     }
249
 
241
 
250
-    _toDateString: Object => string
242
+    _toDateString: Object => string;
251
 
243
 
252
     /**
244
     /**
253
      * Generates a date (interval) string for a given event.
245
      * Generates a date (interval) string for a given event.

+ 3
- 4
react/features/calendar-sync/middleware.js 파일 보기

102
  * @returns {Promise}
102
  * @returns {Promise}
103
  */
103
  */
104
 function _ensureDefaultServer({ dispatch, getState }) {
104
 function _ensureDefaultServer({ dispatch, getState }) {
105
-    const state = getState();
106
     const defaultURL
105
     const defaultURL
107
-        = parseURIString(state['features/app'].app._getDefaultURL());
106
+        = parseURIString(getState()['features/app'].app._getDefaultURL());
108
 
107
 
109
     dispatch(addKnownDomain(defaultURL.host));
108
     dispatch(addKnownDomain(defaultURL.host));
110
 }
109
 }
164
 }
163
 }
165
 
164
 
166
 /**
165
 /**
167
- * Retreives a jitsi URL from an event if present.
166
+ * Retrieves a Jitsi Meet URL from an event if present.
168
  *
167
  *
169
  * @param {Object} event - The event to parse.
168
  * @param {Object} event - The event to parse.
170
  * @param {Array<string>} knownDomains - The known domain names.
169
  * @param {Array<string>} knownDomains - The known domain names.
219
 }
218
 }
220
 
219
 
221
 /**
220
 /**
222
- * Retreives the domain name of a room upon join and stores it in the known
221
+ * Retrieves the domain name of a room upon join and stores it in the known
223
  * domain list, if not present yet.
222
  * domain list, if not present yet.
224
  *
223
  *
225
  * @param {Object} store - The redux store.
224
  * @param {Object} store - The redux store.

+ 13
- 19
react/features/recent-list/components/RecentList.native.js 파일 보기

78
         );
78
         );
79
     }
79
     }
80
 
80
 
81
-    _onPress: string => Function
81
+    _onPress: string => Function;
82
 
82
 
83
     /**
83
     /**
84
      * Handles the list's navigate action.
84
      * Handles the list's navigate action.
93
         dispatch(appNavigate(url));
93
         dispatch(appNavigate(url));
94
     }
94
     }
95
 
95
 
96
-    _toDisplayableItem: Object => Object
96
+    _toDisplayableItem: Object => Object;
97
 
97
 
98
     /**
98
     /**
99
      * Creates a displayable list item of a recent list entry.
99
      * Creates a displayable list item of a recent list entry.
121
         };
121
         };
122
     }
122
     }
123
 
123
 
124
-    _toDisplayableList: () => Array<Object>
124
+    _toDisplayableList: () => Array<Object>;
125
 
125
 
126
     /**
126
     /**
127
      * Transforms the history list to a displayable list
127
      * Transforms the history list to a displayable list
132
      */
132
      */
133
     _toDisplayableList() {
133
     _toDisplayableList() {
134
         const { _recentList, t } = this.props;
134
         const { _recentList, t } = this.props;
135
-        const todaySection = NavigateSectionList.createSection(
136
-            t('recentList.today'),
137
-            'today'
138
-        );
139
-        const yesterdaySection = NavigateSectionList.createSection(
140
-            t('recentList.yesterday'),
141
-            'yesterday'
142
-        );
143
-        const earlierSection = NavigateSectionList.createSection(
144
-            t('recentList.earlier'),
145
-            'earlier'
146
-        );
135
+        const { createSection } = NavigateSectionList;
136
+        const todaySection = createSection(t('recentList.today'), 'today');
137
+        const yesterdaySection
138
+            = createSection(t('recentList.yesterday'), 'yesterday');
139
+        const earlierSection
140
+            = createSection(t('recentList.earlier'), 'earlier');
147
         const today = new Date().toDateString();
141
         const today = new Date().toDateString();
148
         const yesterdayDate = new Date();
142
         const yesterdayDate = new Date();
149
 
143
 
182
         return displayableList;
176
         return displayableList;
183
     }
177
     }
184
 
178
 
185
-    _toDateString: number => string
179
+    _toDateString: number => string;
186
 
180
 
187
     /**
181
     /**
188
      * Generates a date string for the item.
182
      * Generates a date string for the item.
203
         return m.format('lll');
197
         return m.format('lll');
204
     }
198
     }
205
 
199
 
206
-    _toDurationString: number => string
200
+    _toDurationString: number => string;
207
 
201
 
208
     /**
202
     /**
209
      * Generates a duration string for the item.
203
      * Generates a duration string for the item.
226
  *
220
  *
227
  * @param {Object} state - The redux state.
221
  * @param {Object} state - The redux state.
228
  * @returns {{
222
  * @returns {{
229
- *      _defaultServerURL: string,
230
- *      _recentList: Array
223
+ *     _defaultServerURL: string,
224
+ *     _recentList: Array
231
  * }}
225
  * }}
232
  */
226
  */
233
 export function _mapStateToProps(state: Object) {
227
 export function _mapStateToProps(state: Object) {

Loading…
취소
저장