Browse Source

Coding style: utilize default values

Since they are a language feature, they make the source code more easily
comprehensible than `if (typeof XXX === 'undefined') { XXX = ...; }`.
master
Lyubo Marinov 7 years ago
parent
commit
1d128e027a

+ 4
- 5
react/features/base/dialog/components/AbstractDialog.js View File

86
      * @returns {void}
86
      * @returns {void}
87
      */
87
      */
88
     _onCancel() {
88
     _onCancel() {
89
-        const { cancelDisabled, onCancel } = this.props;
89
+        const { cancelDisabled = false, onCancel } = this.props;
90
 
90
 
91
-        if ((typeof cancelDisabled === 'undefined' || !cancelDisabled)
92
-                && (!onCancel || onCancel())) {
91
+        if (!cancelDisabled && (!onCancel || onCancel())) {
93
             this._hide();
92
             this._hide();
94
         }
93
         }
95
     }
94
     }
109
      * @returns {void}
108
      * @returns {void}
110
      */
109
      */
111
     _onSubmit(value: ?string) {
110
     _onSubmit(value: ?string) {
112
-        const { okDisabled, onSubmit } = this.props;
111
+        const { okDisabled = false, onSubmit } = this.props;
113
 
112
 
114
-        if (typeof okDisabled === 'undefined' || !okDisabled) {
113
+        if (!okDisabled) {
115
             this.setState({ submitting: true });
114
             this.setState({ submitting: true });
116
 
115
 
117
             // Invoke the React Compnent prop onSubmit if any.
116
             // Invoke the React Compnent prop onSubmit if any.

+ 2
- 5
react/features/base/react/components/web/Container.js View File

22
      * @returns {ReactElement}
22
      * @returns {ReactElement}
23
      */
23
      */
24
     render() {
24
     render() {
25
-        const { visible } = this.props;
25
+        const { visible = true } = this.props;
26
 
26
 
27
-        return (
28
-            typeof visible === 'undefined' || visible
29
-                ? super._render('div')
30
-                : null);
27
+        return visible ? super._render('div') : null;
31
     }
28
     }
32
 }
29
 }

+ 2
- 2
react/features/calendar-sync/functions.native.js View File

19
  * otherwise, {@code false}.
19
  * otherwise, {@code false}.
20
  */
20
  */
21
 export function isCalendarEnabled() {
21
 export function isCalendarEnabled() {
22
-    const { calendarEnabled } = NativeModules.AppInfo;
22
+    const { calendarEnabled = true } = NativeModules.AppInfo;
23
 
23
 
24
-    return typeof calendarEnabled === 'undefined' ? true : calendarEnabled;
24
+    return calendarEnabled;
25
 }
25
 }
26
 
26
 
27
 /**
27
 /**

+ 0
- 3
react/features/subtitles/components/AbstractClosedCaptionButton.js View File

85
 export function _abstractMapStateToProps(state: Object, ownProps: Object) {
85
 export function _abstractMapStateToProps(state: Object, ownProps: Object) {
86
     const { _requestingSubtitles } = state['features/subtitles'];
86
     const { _requestingSubtitles } = state['features/subtitles'];
87
     const { transcribingEnabled } = state['features/base/config'];
87
     const { transcribingEnabled } = state['features/base/config'];
88
-
89
-    // Default 'visible' to 'transcribingEnabled' if not explicitly specified
90
-    // in the component's properties.
91
     const { visible = transcribingEnabled } = ownProps;
88
     const { visible = transcribingEnabled } = ownProps;
92
 
89
 
93
     return {
90
     return {

Loading…
Cancel
Save