Quellcode durchsuchen

Coding style

master
Lyubo Marinov vor 7 Jahren
Ursprung
Commit
7954d5fd39

+ 6
- 4
react/features/app/components/AbstractApp.js Datei anzeigen

@@ -12,13 +12,13 @@ import {
12 12
     localParticipantJoined,
13 13
     localParticipantLeft
14 14
 } from '../../base/participants';
15
+import { getProfile } from '../../base/profile';
15 16
 import { Fragment, RouteRegistry } from '../../base/react';
16 17
 import {
17 18
     MiddlewareRegistry,
18 19
     PersistencyRegistry,
19 20
     ReducerRegistry
20 21
 } from '../../base/redux';
21
-import { getProfile } from '../../base/profile';
22 22
 import { toURLString } from '../../base/util';
23 23
 import { OverlayContainer } from '../../overlay';
24 24
 import { BlankPage } from '../../welcome';
@@ -346,9 +346,11 @@ export class AbstractApp extends Component {
346 346
             middleware = compose(middleware, devToolsExtension());
347 347
         }
348 348
 
349
-        return createStore(
350
-            reducer, PersistencyRegistry.getPersistedState(), middleware
351
-        );
349
+        return (
350
+            createStore(
351
+                reducer,
352
+                PersistencyRegistry.getPersistedState(),
353
+                middleware));
352 354
     }
353 355
 
354 356
     /**

+ 2
- 4
react/features/base/profile/reducer.js Datei anzeigen

@@ -1,11 +1,9 @@
1 1
 // @flow
2 2
 
3
-import {
4
-    PROFILE_UPDATED
5
-} from './actionTypes';
6
-
7 3
 import { PersistencyRegistry, ReducerRegistry } from '../redux';
8 4
 
5
+import { PROFILE_UPDATED } from './actionTypes';
6
+
9 7
 const DEFAULT_STATE = {
10 8
     profile: {}
11 9
 };

+ 2
- 0
react/features/base/react/prop-types-polyfill.js Datei anzeigen

@@ -2,7 +2,9 @@ import React from 'react';
2 2
 import PropTypes from 'prop-types';
3 3
 
4 4
 /* eslint-disable react/no-deprecated */
5
+
5 6
 if (typeof React.PropTypes === 'undefined') {
6 7
     React.PropTypes = PropTypes;
7 8
 }
9
+
8 10
 /* eslint-enable react/no-deprecated */

+ 32
- 30
react/features/base/redux/PersistencyRegistry.js Datei anzeigen

@@ -1,4 +1,5 @@
1 1
 // @flow
2
+
2 3
 import Logger from 'jitsi-meet-logger';
3 4
 import md5 from 'js-md5';
4 5
 
@@ -15,25 +16,26 @@ const PERSISTED_STATE_NAME = 'jitsi-state';
15 16
 declare type PersistencyConfigMap = { [name: string]: Object };
16 17
 
17 18
 /**
18
- * A registry to allow features to register their redux store
19
- * subtree to be persisted and also handles the persistency calls too.
19
+ * A registry to allow features to register their redux store subtree to be
20
+ * persisted and also handles the persistency calls too.
20 21
  */
21 22
 class PersistencyRegistry {
22 23
     _checksum: string;
24
+
23 25
     _elements: PersistencyConfigMap;
24 26
 
25 27
     /**
26
-     * Initiates the PersistencyRegistry.
28
+     * Initializes a new {@ code PersistencyRegistry} instance.
27 29
      */
28 30
     constructor() {
29 31
         this._elements = {};
30 32
     }
31 33
 
32 34
     /**
33
-     * Returns the persisted redux state. This function takes
34
-     * the PersistencyRegistry._elements into account as we may have
35
-     * persisted something in the past that we don't want to retreive anymore.
36
-     * The next {@link #persistState} will remove those values.
35
+     * Returns the persisted redux state. This function takes the
36
+     * {@link #_elements} into account as we may have persisted something in the
37
+     * past that we don't want to retreive anymore. The next
38
+     * {@link #persistState} will remove those values.
37 39
      *
38 40
      * @returns {Object}
39 41
      */
@@ -46,8 +48,9 @@ class PersistencyRegistry {
46 48
                 persistedState = JSON.parse(persistedState);
47 49
             } catch (error) {
48 50
                 logger.error(
49
-                    'Error parsing persisted state', persistedState, error
50
-                );
51
+                    'Error parsing persisted state',
52
+                    persistedState,
53
+                    error);
51 54
                 persistedState = {};
52 55
             }
53 56
 
@@ -56,14 +59,14 @@ class PersistencyRegistry {
56 59
         }
57 60
 
58 61
         this._checksum = this._calculateChecksum(filteredPersistedState);
59
-        logger.info('Redux state rehydrated as', filteredPersistedState);
62
+        logger.info('redux state rehydrated as', filteredPersistedState);
60 63
 
61 64
         return filteredPersistedState;
62 65
     }
63 66
 
64 67
     /**
65
-     * Initiates a persist operation, but its execution will depend on
66
-     * the current checksums (checks changes).
68
+     * Initiates a persist operation, but its execution will depend on the
69
+     * current checksums (checks changes).
67 70
      *
68 71
      * @param {Object} state - The redux state.
69 72
      * @returns {void}
@@ -76,14 +79,13 @@ class PersistencyRegistry {
76 79
             try {
77 80
                 window.localStorage.setItem(
78 81
                     PERSISTED_STATE_NAME,
79
-                    JSON.stringify(filteredState)
80
-                );
82
+                    JSON.stringify(filteredState));
81 83
                 logger.info(
82
-                    `Redux state persisted. ${this._checksum} -> ${newCheckSum}`
83
-                );
84
+                    `redux state persisted. ${this._checksum} -> ${
85
+                        newCheckSum}`);
84 86
                 this._checksum = newCheckSum;
85 87
             } catch (error) {
86
-                logger.error('Error persisting Redux state', error);
88
+                logger.error('Error persisting redux state', error);
87 89
             }
88 90
         }
89 91
     }
@@ -103,7 +105,7 @@ class PersistencyRegistry {
103 105
      * Calculates the checksum of the current or the new values of the state.
104 106
      *
105 107
      * @private
106
-     * @param {Object} filteredState - The filtered/persisted Redux state.
108
+     * @param {Object} filteredState - The filtered/persisted redux state.
107 109
      * @returns {string}
108 110
      */
109 111
     _calculateChecksum(filteredState: Object) {
@@ -111,16 +113,17 @@ class PersistencyRegistry {
111 113
             return md5.hex(JSON.stringify(filteredState) || '');
112 114
         } catch (error) {
113 115
             logger.error(
114
-                'Error calculating checksum for state', filteredState, error
115
-            );
116
+                'Error calculating checksum for state',
117
+                filteredState,
118
+                error);
116 119
 
117 120
             return '';
118 121
         }
119 122
     }
120 123
 
121 124
     /**
122
-     * Prepares a filtered state from the actual or the
123
-     * persisted Redux state, based on this registry.
125
+     * Prepares a filtered state from the actual or the persisted redux state,
126
+     * based on this registry.
124 127
      *
125 128
      * @private
126 129
      * @param {Object} state - The actual or persisted redux state.
@@ -131,10 +134,10 @@ class PersistencyRegistry {
131 134
 
132 135
         for (const name of Object.keys(this._elements)) {
133 136
             if (state[name]) {
134
-                filteredState[name] = this._getFilteredSubtree(
135
-                    state[name],
136
-                    this._elements[name]
137
-                );
137
+                filteredState[name]
138
+                    = this._getFilteredSubtree(
139
+                        state[name],
140
+                        this._elements[name]);
138 141
             }
139 142
         }
140 143
 
@@ -142,8 +145,8 @@ class PersistencyRegistry {
142 145
     }
143 146
 
144 147
     /**
145
-     * Prepares a filtered subtree based on the config for
146
-     * persisting or for retreival.
148
+     * Prepares a filtered subtree based on the config for persisting or for
149
+     * retrieval.
147 150
      *
148 151
      * @private
149 152
      * @param {Object} subtree - The redux state subtree.
@@ -155,8 +158,7 @@ class PersistencyRegistry {
155 158
 
156 159
         for (const persistedKey of Object.keys(subtree)) {
157 160
             if (subtreeConfig[persistedKey]) {
158
-                filteredSubtree[persistedKey]
159
-                    = subtree[persistedKey];
161
+                filteredSubtree[persistedKey] = subtree[persistedKey];
160 162
             }
161 163
         }
162 164
 

+ 1
- 1
react/features/base/redux/functions.js Datei anzeigen

@@ -1,4 +1,4 @@
1
-/* @flow */
1
+// @flow
2 2
 
3 3
 import _ from 'lodash';
4 4
 

+ 13
- 12
react/features/base/redux/middleware.js Datei anzeigen

@@ -1,28 +1,29 @@
1
-/* @flow */
1
+// @flow
2
+
2 3
 import _ from 'lodash';
3 4
 
5
+import { toState } from './functions';
4 6
 import MiddlewareRegistry from './MiddlewareRegistry';
5 7
 import PersistencyRegistry from './PersistencyRegistry';
6 8
 
7
-import { toState } from '../redux';
8
-
9 9
 /**
10
- * The delay that passes between the last state change and the state to be
11
- * persisted in the storage.
10
+ * The delay that passes between the last state change and the persisting of
11
+ * that state in the storage.
12 12
  */
13
-const PERSIST_DELAY = 2000;
13
+const PERSIST_STATE_DELAY = 2000;
14 14
 
15 15
 /**
16 16
  * A throttled function to avoid repetitive state persisting.
17 17
  */
18
-const throttledFunc = _.throttle(state => {
19
-    PersistencyRegistry.persistState(state);
20
-}, PERSIST_DELAY);
18
+const throttledPersistState
19
+    = _.throttle(
20
+        state => PersistencyRegistry.persistState(state),
21
+        PERSIST_STATE_DELAY);
21 22
 
22 23
 /**
23 24
  * A master MiddleWare to selectively persist state. Please use the
24
- * {@link persisterconfig.json} to set which subtrees of the Redux state
25
- * should be persisted.
25
+ * {@link persisterconfig.json} to set which subtrees of the Redux state should
26
+ * be persisted.
26 27
  *
27 28
  * @param {Store} store - The redux store.
28 29
  * @returns {Function}
@@ -30,7 +31,7 @@ const throttledFunc = _.throttle(state => {
30 31
 MiddlewareRegistry.register(store => next => action => {
31 32
     const result = next(action);
32 33
 
33
-    throttledFunc(toState(store));
34
+    throttledPersistState(toState(store));
34 35
 
35 36
     return result;
36 37
 });

+ 4
- 4
react/features/recent-list/actions.js Datei anzeigen

@@ -10,8 +10,8 @@ import {
10 10
  *
11 11
  * @param {Object} locationURL - The current location URL.
12 12
  * @returns {{
13
- *      type: STORE_CURRENT_CONFERENCE,
14
- *      locationURL: Object
13
+ *     type: STORE_CURRENT_CONFERENCE,
14
+ *     locationURL: Object
15 15
  * }}
16 16
  */
17 17
 export function storeCurrentConference(locationURL: Object) {
@@ -26,8 +26,8 @@ export function storeCurrentConference(locationURL: Object) {
26 26
  *
27 27
  * @param {Object} locationURL - The current location URL.
28 28
  * @returns {{
29
- *      type: UPDATE_CONFERENCE_DURATION,
30
- *      locationURL: Object
29
+ *     type: UPDATE_CONFERENCE_DURATION,
30
+ *     locationURL: Object
31 31
  * }}
32 32
  */
33 33
 export function updateConferenceDuration(locationURL: Object) {

+ 6
- 7
react/features/recent-list/components/RecentList.native.js Datei anzeigen

@@ -2,12 +2,11 @@ import React from 'react';
2 2
 import { ListView, Text, TouchableHighlight, View } from 'react-native';
3 3
 import { connect } from 'react-redux';
4 4
 
5
-import AbstractRecentList, { _mapStateToProps } from './AbstractRecentList';
6
-import styles, { UNDERLAY_COLOR } from './styles';
5
+import { Icon } from '../../base/font-icons';
7 6
 
7
+import AbstractRecentList, { _mapStateToProps } from './AbstractRecentList';
8 8
 import { getRecentRooms } from '../functions';
9
-
10
-import { Icon } from '../../base/font-icons';
9
+import styles, { UNDERLAY_COLOR } from './styles';
11 10
 
12 11
 /**
13 12
  * The native container rendering the list of the recently joined rooms.
@@ -52,9 +51,9 @@ class RecentList extends AbstractRecentList {
52 51
             return null;
53 52
         }
54 53
 
55
-        const listViewDataSource = this.dataSource.cloneWithRows(
56
-            getRecentRooms(this.props._recentList)
57
-        );
54
+        const listViewDataSource
55
+            = this.dataSource.cloneWithRows(
56
+                getRecentRooms(this.props._recentList));
58 57
 
59 58
         return (
60 59
             <View style = { styles.container }>

+ 13
- 15
react/features/recent-list/functions.js Datei anzeigen

@@ -2,16 +2,11 @@
2 2
 
3 3
 import moment from 'moment';
4 4
 
5
-import { i18next } from '../base/i18n';
6
-import { parseURIString } from '../base/util';
7
-
8
-/**
9
- * MomentJS uses static language bundle loading, so in order to support dynamic
10
- * language selection in the app we need to load all bundles that we support in
11
- * the app.
12
- * FIXME: If we decide to support MomentJS in other features as well we may need
13
- * to move this import and the lenient matcher to the i18n feature.
14
- */
5
+// MomentJS uses static language bundle loading, so in order to support dynamic
6
+// language selection in the app we need to load all bundles that we support in
7
+// the app.
8
+// FIXME: If we decide to support MomentJS in other features as well we may need
9
+// to move this import and the lenient matcher to the i18n feature.
15 10
 require('moment/locale/bg');
16 11
 require('moment/locale/de');
17 12
 require('moment/locale/eo');
@@ -33,6 +28,9 @@ require('moment/locale/sv');
33 28
 require('moment/locale/tr');
34 29
 require('moment/locale/zh-cn');
35 30
 
31
+import { i18next } from '../base/i18n';
32
+import { parseURIString } from '../base/util';
33
+
36 34
 /**
37 35
  * Retrieves the recent room list and generates all the data needed to be
38 36
  * displayed.
@@ -122,14 +120,14 @@ function _getInitials(room: string) {
122 120
 }
123 121
 
124 122
 /**
125
- * Returns a localized date formatter initialized with the provided date
126
- * (@code Date) or duration (@code number).
123
+ * Returns a localized date formatter initialized with a specific {@code Date}
124
+ * or duration ({@code number}).
127 125
  *
128 126
  * @private
129 127
  * @param {Date | number} dateOrDuration - The date or duration to format.
130
- * @param {string} locale - The locale to init the formatter with. Note: This
131
- * locale must be supported by the formatter so ensure this prerequisite before
132
- * invoking the function.
128
+ * @param {string} locale - The locale to init the formatter with. Note: The
129
+ * specified locale must be supported by the formatter so ensure the
130
+ * prerequisite is met before invoking the function.
133 131
  * @returns {Object}
134 132
  */
135 133
 function _getLocalizedFormatter(dateOrDuration: Date | number, locale: string) {

+ 5
- 5
react/features/recent-list/reducer.js Datei anzeigen

@@ -1,13 +1,13 @@
1 1
 // @flow
2 2
 
3
+import { PersistencyRegistry, ReducerRegistry } from '../base/redux';
4
+
3 5
 import {
4 6
     STORE_CURRENT_CONFERENCE,
5 7
     UPDATE_CONFERENCE_DURATION
6 8
 } from './actionTypes';
7 9
 import { LIST_SIZE } from './constants';
8 10
 
9
-import { PersistencyRegistry, ReducerRegistry } from '../base/redux';
10
-
11 11
 /**
12 12
  * The initial state of this feature.
13 13
  */
@@ -34,8 +34,10 @@ ReducerRegistry.register(STORE_NAME, (state = DEFAULT_STATE, action) => {
34 34
     switch (action.type) {
35 35
     case STORE_CURRENT_CONFERENCE:
36 36
         return _storeCurrentConference(state, action);
37
+
37 38
     case UPDATE_CONFERENCE_DURATION:
38 39
         return _updateConferenceDuration(state, action);
40
+
39 41
     default:
40 42
         return state;
41 43
     }
@@ -54,9 +56,7 @@ function _storeCurrentConference(state, action) {
54 56
 
55 57
     // If the current conference is already in the list, we remove it to re-add
56 58
     // it to the top.
57
-    const list
58
-        = state.list
59
-            .filter(e => e.conference !== conference);
59
+    const list = state.list.filter(e => e.conference !== conference);
60 60
 
61 61
     // This is a reverse sorted array (i.e. newer elements at the end).
62 62
     list.push({

Laden…
Abbrechen
Speichern