소스 검색

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 년 전
부모
커밋
1d128e027a

+ 4
- 5
react/features/base/dialog/components/AbstractDialog.js 파일 보기

@@ -86,10 +86,9 @@ export default class AbstractDialog<P : Props, S : State>
86 86
      * @returns {void}
87 87
      */
88 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 92
             this._hide();
94 93
         }
95 94
     }
@@ -109,9 +108,9 @@ export default class AbstractDialog<P : Props, S : State>
109 108
      * @returns {void}
110 109
      */
111 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 114
             this.setState({ submitting: true });
116 115
 
117 116
             // Invoke the React Compnent prop onSubmit if any.

+ 2
- 5
react/features/base/react/components/web/Container.js 파일 보기

@@ -22,11 +22,8 @@ export default class Container extends AbstractContainer {
22 22
      * @returns {ReactElement}
23 23
      */
24 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 파일 보기

@@ -19,9 +19,9 @@ const logger = require('jitsi-meet-logger').getLogger(__filename);
19 19
  * otherwise, {@code false}.
20 20
  */
21 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 파일 보기

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

Loading…
취소
저장