Procházet zdrojové kódy

Consistent naming of Component props mapped from the Redux state

Until we make a decision on access modifier hints and adopt a respective
coding style, consistency is king.
j8
Lyubomir Marinov před 8 roky
rodič
revize
3aff812ee2

+ 16
- 4
react/features/film-strip/components/FilmStrip.js Zobrazit soubor

@@ -19,7 +19,13 @@ class FilmStrip extends Component {
19 19
      * @static
20 20
      */
21 21
     static propTypes = {
22
-        participants: React.PropTypes.array,
22
+        /**
23
+         * The participants in the conference.
24
+         *
25
+         * @private
26
+         * @type {Participant[]}
27
+         */
28
+        _participants: React.PropTypes.array,
23 29
         visible: React.PropTypes.bool.isRequired
24 30
     }
25 31
 
@@ -43,7 +49,7 @@ class FilmStrip extends Component {
43 49
                     showsHorizontalScrollIndicator = { false }
44 50
                     showsVerticalScrollIndicator = { false }>
45 51
                     {
46
-                        this._sort(this.props.participants)
52
+                        this._sort(this.props._participants)
47 53
                             .map(p =>
48 54
                                 <Thumbnail
49 55
                                     key = { p.id }
@@ -94,12 +100,18 @@ class FilmStrip extends Component {
94 100
  *
95 101
  * @param {Object} state - Redux state.
96 102
  * @returns {{
97
- *      participants: Participant[],
103
+ *      _participants: Participant[],
98 104
  *  }}
99 105
  */
100 106
 function mapStateToProps(state) {
101 107
     return {
102
-        participants: state['features/base/participants']
108
+        /**
109
+         * The participants in the conference.
110
+         *
111
+         * @private
112
+         * @type {Participant[]}
113
+         */
114
+        _participants: state['features/base/participants']
103 115
     };
104 116
 }
105 117
 

+ 14
- 16
react/features/film-strip/components/Thumbnail.js Zobrazit soubor

@@ -26,11 +26,11 @@ class Thumbnail extends Component {
26 26
      * @static
27 27
      */
28 28
     static propTypes = {
29
-        audioTrack: React.PropTypes.object,
29
+        _audioTrack: React.PropTypes.object,
30
+        _largeVideo: React.PropTypes.object,
31
+        _videoTrack: React.PropTypes.object,
30 32
         dispatch: React.PropTypes.func,
31
-        largeVideo: React.PropTypes.object,
32
-        participant: React.PropTypes.object,
33
-        videoTrack: React.PropTypes.object
33
+        participant: React.PropTypes.object
34 34
     }
35 35
 
36 36
     /**
@@ -64,12 +64,10 @@ class Thumbnail extends Component {
64 64
      * @returns {ReactElement}
65 65
      */
66 66
     render() {
67
-        const {
68
-            audioTrack,
69
-            largeVideo,
70
-            participant,
71
-            videoTrack
72
-        } = this.props;
67
+        const audioTrack = this.props._audioTrack;
68
+        const largeVideo = this.props._largeVideo;
69
+        const participant = this.props.participant;
70
+        const videoTrack = this.props._videoTrack;
73 71
 
74 72
         let style = styles.thumbnail;
75 73
 
@@ -136,9 +134,9 @@ class Thumbnail extends Component {
136 134
  * @param {Object} state - Redux state.
137 135
  * @param {Object} ownProps - Properties of component.
138 136
  * @returns {{
139
- *      audioTrack: Track,
140
- *      largeVideo: Object,
141
- *      videoTrack: Track
137
+ *      _audioTrack: Track,
138
+ *      _largeVideo: Object,
139
+ *      _videoTrack: Track
142 140
  *  }}
143 141
  */
144 142
 function mapStateToProps(state, ownProps) {
@@ -154,9 +152,9 @@ function mapStateToProps(state, ownProps) {
154 152
         = getTrackByMediaTypeAndParticipant(tracks, MEDIA_TYPE.VIDEO, id);
155 153
 
156 154
     return {
157
-        audioTrack,
158
-        largeVideo,
159
-        videoTrack
155
+        _audioTrack: audioTrack,
156
+        _largeVideo: largeVideo,
157
+        _videoTrack: videoTrack
160 158
     };
161 159
 }
162 160
 

+ 17
- 9
react/features/toolbar/components/AbstractToolbar.js Zobrazit soubor

@@ -19,15 +19,18 @@ export class AbstractToolbar extends Component {
19 19
      * @static
20 20
      */
21 21
     static propTypes = {
22
-        audioMuted: React.PropTypes.bool,
23
-        dispatch: React.PropTypes.func,
22
+        _audioMuted: React.PropTypes.bool,
24 23
 
25 24
         /**
26 25
          * The indicator which determines whether the conference is
27 26
          * locked/password-protected.
27
+         *
28
+         * @protected
29
+         * @type {boolean}
28 30
          */
29
-        locked: React.PropTypes.bool,
30
-        videoMuted: React.PropTypes.bool,
31
+        _locked: React.PropTypes.bool,
32
+        _videoMuted: React.PropTypes.bool,
33
+        dispatch: React.PropTypes.func,
31 34
         visible: React.PropTypes.bool.isRequired
32 35
     }
33 36
 
@@ -65,7 +68,7 @@ export class AbstractToolbar extends Component {
65 68
         let iconStyle;
66 69
         let style = styles.primaryToolbarButton;
67 70
 
68
-        if (this.props[`${mediaType}Muted`]) {
71
+        if (this.props[`_${mediaType}Muted`]) {
69 72
             iconName = this[`${mediaType}MutedIcon`];
70 73
             iconStyle = styles.whiteIcon;
71 74
             style = {
@@ -135,22 +138,27 @@ export class AbstractToolbar extends Component {
135 138
  * Maps parts of media state to component props.
136 139
  *
137 140
  * @param {Object} state - Redux state.
138
- * @returns {{ audioMuted: boolean, videoMuted: boolean }}
141
+ * @returns {{
142
+ *     _audioMuted: boolean,
143
+ *     _locked: boolean,
144
+ *     _videoMuted: boolean
145
+ * }}
139 146
  */
140 147
 export function mapStateToProps(state) {
141 148
     const conference = state['features/base/conference'];
142 149
     const media = state['features/base/media'];
143 150
 
144 151
     return {
145
-        audioMuted: media.audio.muted,
152
+        _audioMuted: media.audio.muted,
146 153
 
147 154
         /**
148 155
          * The indicator which determines whether the conference is
149 156
          * locked/password-protected.
150 157
          *
158
+         * @protected
151 159
          * @type {boolean}
152 160
          */
153
-        locked: conference.locked,
154
-        videoMuted: media.video.muted
161
+        _locked: conference.locked,
162
+        _videoMuted: media.video.muted
155 163
     };
156 164
 }

+ 1
- 1
react/features/toolbar/components/Toolbar.native.js Zobrazit soubor

@@ -123,7 +123,7 @@ class Toolbar extends AbstractToolbar {
123 123
                     underlayColor = { underlayColor } />
124 124
                 <ToolbarButton
125 125
                     iconName = {
126
-                        this.props.locked ? 'security-locked' : 'security'
126
+                        this.props._locked ? 'security-locked' : 'security'
127 127
                     }
128 128
                     iconStyle = { iconStyle }
129 129
                     onClick = { this._onRoomLock }

+ 9
- 9
react/features/welcome/components/AbstractWelcomePage.js Zobrazit soubor

@@ -18,9 +18,9 @@ export class AbstractWelcomePage extends Component {
18 18
      * @static
19 19
      */
20 20
     static propTypes = {
21
-        dispatch: React.PropTypes.func,
22
-        localVideoTrack: React.PropTypes.object,
23
-        room: React.PropTypes.string
21
+        _localVideoTrack: React.PropTypes.object,
22
+        _room: React.PropTypes.string,
23
+        dispatch: React.PropTypes.func
24 24
     }
25 25
 
26 26
     /**
@@ -69,7 +69,7 @@ export class AbstractWelcomePage extends Component {
69 69
      * @param {Object} nextProps - New props component will receive.
70 70
      */
71 71
     componentWillReceiveProps(nextProps) {
72
-        this.setState({ room: nextProps.room });
72
+        this.setState({ room: nextProps._room });
73 73
     }
74 74
 
75 75
     /**
@@ -167,7 +167,7 @@ export class AbstractWelcomePage extends Component {
167 167
      */
168 168
     _renderLocalVideo() {
169 169
         return (
170
-            <VideoTrack videoTrack = { this.props.localVideoTrack } />
170
+            <VideoTrack videoTrack = { this.props._localVideoTrack } />
171 171
         );
172 172
     }
173 173
 
@@ -202,8 +202,8 @@ export class AbstractWelcomePage extends Component {
202 202
  *
203 203
  * @param {Object} state - Redux state.
204 204
  * @returns {{
205
- *      localVideoTrack: (Track|undefined),
206
- *      room: string
205
+ *     _localVideoTrack: (Track|undefined),
206
+ *     _room: string
207 207
  * }}
208 208
  */
209 209
 export function mapStateToProps(state) {
@@ -211,7 +211,7 @@ export function mapStateToProps(state) {
211 211
     const tracks = state['features/base/tracks'];
212 212
 
213 213
     return {
214
-        localVideoTrack: getLocalVideoTrack(tracks),
215
-        room: conference.room
214
+        _localVideoTrack: getLocalVideoTrack(tracks),
215
+        _room: conference.room
216 216
     };
217 217
 }

Načítá se…
Zrušit
Uložit