Ver código fonte

fix(optimise): mapStateToProps for some components (#5085)

j8
Hristo Terezov 5 anos atrás
pai
commit
bd8a7edbd2
Nenhuma conta vinculada ao e-mail do autor do commit

+ 4
- 1
react/features/chrome-extension-banner/components/ChromeExtensionBanner.web.js Ver arquivo

17
 
17
 
18
 declare var interfaceConfig: Object;
18
 declare var interfaceConfig: Object;
19
 
19
 
20
+const emptyObject = {};
21
+
20
 /**
22
 /**
21
  * Local storage key name for flag telling if user checked 'Don't show again' checkbox on the banner
23
  * Local storage key name for flag telling if user checked 'Don't show again' checkbox on the banner
22
  * If the user checks this before closing the banner, next time he will access a jitsi domain
24
  * If the user checks this before closing the banner, next time he will access a jitsi domain
271
  */
273
  */
272
 const _mapStateToProps = state => {
274
 const _mapStateToProps = state => {
273
     return {
275
     return {
274
-        bannerCfg: state['features/base/config'].chromeExtensionBanner || {},
276
+        // Using emptyObject so that we don't change the reference every time when _mapStateToProps is called.
277
+        bannerCfg: state['features/base/config'].chromeExtensionBanner || emptyObject,
275
         conference: getCurrentConference(state),
278
         conference: getCurrentConference(state),
276
         iAmRecorder: state['features/base/config'].iAmRecorder
279
         iAmRecorder: state['features/base/config'].iAmRecorder
277
     };
280
     };

+ 5
- 1
react/features/filmstrip/components/web/Toolbar.js Ver arquivo

12
 
12
 
13
 declare var interfaceConfig: Object;
13
 declare var interfaceConfig: Object;
14
 
14
 
15
+// XXX: We are not currently using state here, but in the future, when
16
+// interfaceConfig is part of redux we will. This has to be retrieved from the store.
17
+const visibleButtons = new Set(interfaceConfig.TOOLBAR_BUTTONS);
18
+
15
 /**
19
 /**
16
  * The type of the React {@code Component} props of {@link Toolbar}.
20
  * The type of the React {@code Component} props of {@link Toolbar}.
17
  */
21
  */
86
     // interfaceConfig is part of redux we will.
90
     // interfaceConfig is part of redux we will.
87
 
91
 
88
     return {
92
     return {
89
-        _visibleButtons: new Set(interfaceConfig.TOOLBAR_BUTTONS)
93
+        _visibleButtons: visibleButtons
90
     };
94
     };
91
 }
95
 }
92
 
96
 

+ 7
- 5
react/features/invite/components/info-dialog/web/InfoDialog.js Ver arquivo

59
     /**
59
     /**
60
      * The redux representation of the local participant.
60
      * The redux representation of the local participant.
61
      */
61
      */
62
-    _localParticipant: Object,
62
+    _localParticipantName: ?string,
63
 
63
 
64
     /**
64
     /**
65
      * The current location url of the conference.
65
      * The current location url of the conference.
316
      * @returns {string}
316
      * @returns {string}
317
      */
317
      */
318
     _getTextToCopy() {
318
     _getTextToCopy() {
319
-        const { _localParticipant, liveStreamViewURL, t } = this.props;
319
+        const { _localParticipantName, liveStreamViewURL, t } = this.props;
320
         const _inviteURL = _decodeRoomURI(this.props._inviteURL);
320
         const _inviteURL = _decodeRoomURI(this.props._inviteURL);
321
 
321
 
322
-        let invite = _localParticipant && _localParticipant.name
323
-            ? t('info.inviteURLFirstPartPersonal', { name: _localParticipant.name })
322
+        let invite = _localParticipantName
323
+            ? t('info.inviteURLFirstPartPersonal', { name: _localParticipantName })
324
             : t('info.inviteURLFirstPartGeneral');
324
             : t('info.inviteURLFirstPartGeneral');
325
 
325
 
326
         invite += t('info.inviteURLSecondPart', {
326
         invite += t('info.inviteURLSecondPart', {
613
  *     _conference: Object,
613
  *     _conference: Object,
614
  *     _conferenceName: string,
614
  *     _conferenceName: string,
615
  *     _inviteURL: string,
615
  *     _inviteURL: string,
616
+ *     _localParticipantName: ?string,
616
  *     _locationURL: string,
617
  *     _locationURL: string,
617
  *     _locked: string,
618
  *     _locked: string,
618
  *     _password: string
619
  *     _password: string
625
         password,
626
         password,
626
         room
627
         room
627
     } = state['features/base/conference'];
628
     } = state['features/base/conference'];
629
+    const localParticipant = getLocalParticipant(state);
628
 
630
 
629
     return {
631
     return {
630
         _canEditPassword: isLocalParticipantModerator(state, state['features/base/config'].lockRoomGuestEnabled),
632
         _canEditPassword: isLocalParticipantModerator(state, state['features/base/config'].lockRoomGuestEnabled),
632
         _conferenceName: room,
634
         _conferenceName: room,
633
         _passwordNumberOfDigits: state['features/base/config'].roomPasswordNumberOfDigits,
635
         _passwordNumberOfDigits: state['features/base/config'].roomPasswordNumberOfDigits,
634
         _inviteURL: getInviteURL(state),
636
         _inviteURL: getInviteURL(state),
635
-        _localParticipant: getLocalParticipant(state),
637
+        _localParticipantName: localParticipant?.name,
636
         _locationURL: state['features/base/connection'].locationURL,
638
         _locationURL: state['features/base/connection'].locationURL,
637
         _locked: locked,
639
         _locked: locked,
638
         _password: password
640
         _password: password

+ 5
- 5
react/features/invite/components/info-dialog/web/InfoDialogButton.js Ver arquivo

47
     _liveStreamViewURL: ?string,
47
     _liveStreamViewURL: ?string,
48
 
48
 
49
     /**
49
     /**
50
-     * The number of real participants in the call. If in a lonely call, the
50
+     * True if the number of real participants in the call is less than 2. If in a lonely call, the
51
      * {@code InfoDialog} will be automatically shown.
51
      * {@code InfoDialog} will be automatically shown.
52
      */
52
      */
53
-    _participantCount: number,
53
+    _isLonelyCall: boolean,
54
 
54
 
55
     /**
55
     /**
56
      * Whether or not the toolbox, in which this component exists, is visible.
56
      * Whether or not the toolbox, in which this component exists, is visible.
108
             showDialog: (props._toolboxVisible && state.showDialog)
108
             showDialog: (props._toolboxVisible && state.showDialog)
109
                 || (!state.hasConnectedToConference
109
                 || (!state.hasConnectedToConference
110
                     && props._isConferenceJoined
110
                     && props._isConferenceJoined
111
-                    && props._participantCount < 2
111
+                    && props._isLonelyCall
112
                     && props._toolboxVisible
112
                     && props._toolboxVisible
113
                     && !props._disableAutoShow)
113
                     && !props._disableAutoShow)
114
         };
114
         };
243
  *     _disableAutoShow: boolean,
243
  *     _disableAutoShow: boolean,
244
  *     _isConferenceIsJoined: boolean,
244
  *     _isConferenceIsJoined: boolean,
245
  *     _liveStreamViewURL: string,
245
  *     _liveStreamViewURL: string,
246
- *     _participantCount: number,
246
+ *     _isLonelyCall: boolean,
247
  *     _toolboxVisible: boolean
247
  *     _toolboxVisible: boolean
248
  * }}
248
  * }}
249
  */
249
  */
260
         _liveStreamViewURL:
260
         _liveStreamViewURL:
261
             currentLiveStreamingSession
261
             currentLiveStreamingSession
262
                 && currentLiveStreamingSession.liveStreamViewURL,
262
                 && currentLiveStreamingSession.liveStreamViewURL,
263
-        _participantCount: getParticipantCount(state),
263
+        _isLonelyCall: getParticipantCount(state) < 2,
264
         _toolboxVisible: state['features/toolbox'].visible
264
         _toolboxVisible: state['features/toolbox'].visible
265
     };
265
     };
266
 }
266
 }

+ 6
- 3
react/features/subtitles/components/AbstractCaptions.js Ver arquivo

17
      * Mapped by id just to have the keys for convenience during the rendering
17
      * Mapped by id just to have the keys for convenience during the rendering
18
      * process.
18
      * process.
19
      */
19
      */
20
-    _transcripts: Map<string, string>
20
+    _transcripts: ?Map<string, string>
21
 };
21
 };
22
 
22
 
23
 /**
23
 /**
36
     render() {
36
     render() {
37
         const { _requestingSubtitles, _transcripts } = this.props;
37
         const { _requestingSubtitles, _transcripts } = this.props;
38
 
38
 
39
-        if (!_requestingSubtitles || !_transcripts.size) {
39
+        if (!_requestingSubtitles || !_transcripts || !_transcripts.size) {
40
             return null;
40
             return null;
41
         }
41
         }
42
 
42
 
120
  */
120
  */
121
 export function _abstractMapStateToProps(state: Object) {
121
 export function _abstractMapStateToProps(state: Object) {
122
     const { _requestingSubtitles } = state['features/subtitles'];
122
     const { _requestingSubtitles } = state['features/subtitles'];
123
+    const transcripts = _constructTranscripts(state);
123
 
124
 
124
     return {
125
     return {
125
         _requestingSubtitles,
126
         _requestingSubtitles,
126
-        _transcripts: _constructTranscripts(state)
127
+
128
+        // avoid rerenders by setting to props new empty Map instances.
129
+        _transcripts: transcripts.size === 0 ? undefined : transcripts
127
     };
130
     };
128
 }
131
 }

+ 5
- 4
react/features/toolbox/components/web/Toolbox.js Ver arquivo

206
 declare var APP: Object;
206
 declare var APP: Object;
207
 declare var interfaceConfig: Object;
207
 declare var interfaceConfig: Object;
208
 
208
 
209
+// XXX: We are not currently using state here, but in the future, when
210
+// interfaceConfig is part of redux we will. This will have to be retrieved from the store.
211
+const visibleButtons = new Set(interfaceConfig.TOOLBAR_BUTTONS);
212
+
209
 /**
213
 /**
210
  * Implements the conference toolbox on React/Web.
214
  * Implements the conference toolbox on React/Web.
211
  *
215
  *
1347
             || sharedVideoStatus === 'start'
1351
             || sharedVideoStatus === 'start'
1348
             || sharedVideoStatus === 'pause',
1352
             || sharedVideoStatus === 'pause',
1349
         _visible: isToolboxVisible(state),
1353
         _visible: isToolboxVisible(state),
1350
-
1351
-        // XXX: We are not currently using state here, but in the future, when
1352
-        // interfaceConfig is part of redux we will.
1353
-        _visibleButtons: new Set(interfaceConfig.TOOLBAR_BUTTONS)
1354
+        _visibleButtons: visibleButtons
1354
     };
1355
     };
1355
 }
1356
 }
1356
 
1357
 

Carregando…
Cancelar
Salvar