From 1d128e027a41bc16b19cfb1e5188c1e5b8ce9db8 Mon Sep 17 00:00:00 2001 From: Lyubo Marinov Date: Fri, 7 Sep 2018 12:40:10 -0500 Subject: [PATCH] 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 = ...; }`. --- react/features/base/dialog/components/AbstractDialog.js | 9 ++++----- react/features/base/react/components/web/Container.js | 7 ++----- react/features/calendar-sync/functions.native.js | 4 ++-- .../subtitles/components/AbstractClosedCaptionButton.js | 3 --- 4 files changed, 8 insertions(+), 15 deletions(-) diff --git a/react/features/base/dialog/components/AbstractDialog.js b/react/features/base/dialog/components/AbstractDialog.js index 4d9bfa562..3b32ea257 100644 --- a/react/features/base/dialog/components/AbstractDialog.js +++ b/react/features/base/dialog/components/AbstractDialog.js @@ -86,10 +86,9 @@ export default class AbstractDialog

* @returns {void} */ _onCancel() { - const { cancelDisabled, onCancel } = this.props; + const { cancelDisabled = false, onCancel } = this.props; - if ((typeof cancelDisabled === 'undefined' || !cancelDisabled) - && (!onCancel || onCancel())) { + if (!cancelDisabled && (!onCancel || onCancel())) { this._hide(); } } @@ -109,9 +108,9 @@ export default class AbstractDialog

* @returns {void} */ _onSubmit(value: ?string) { - const { okDisabled, onSubmit } = this.props; + const { okDisabled = false, onSubmit } = this.props; - if (typeof okDisabled === 'undefined' || !okDisabled) { + if (!okDisabled) { this.setState({ submitting: true }); // Invoke the React Compnent prop onSubmit if any. diff --git a/react/features/base/react/components/web/Container.js b/react/features/base/react/components/web/Container.js index 3f1face99..721d4b731 100644 --- a/react/features/base/react/components/web/Container.js +++ b/react/features/base/react/components/web/Container.js @@ -22,11 +22,8 @@ export default class Container extends AbstractContainer { * @returns {ReactElement} */ render() { - const { visible } = this.props; + const { visible = true } = this.props; - return ( - typeof visible === 'undefined' || visible - ? super._render('div') - : null); + return visible ? super._render('div') : null; } } diff --git a/react/features/calendar-sync/functions.native.js b/react/features/calendar-sync/functions.native.js index a74e33c4e..f2c743b55 100644 --- a/react/features/calendar-sync/functions.native.js +++ b/react/features/calendar-sync/functions.native.js @@ -19,9 +19,9 @@ const logger = require('jitsi-meet-logger').getLogger(__filename); * otherwise, {@code false}. */ export function isCalendarEnabled() { - const { calendarEnabled } = NativeModules.AppInfo; + const { calendarEnabled = true } = NativeModules.AppInfo; - return typeof calendarEnabled === 'undefined' ? true : calendarEnabled; + return calendarEnabled; } /** diff --git a/react/features/subtitles/components/AbstractClosedCaptionButton.js b/react/features/subtitles/components/AbstractClosedCaptionButton.js index 61d833e2c..c76afeacd 100644 --- a/react/features/subtitles/components/AbstractClosedCaptionButton.js +++ b/react/features/subtitles/components/AbstractClosedCaptionButton.js @@ -85,9 +85,6 @@ export class AbstractClosedCaptionButton export function _abstractMapStateToProps(state: Object, ownProps: Object) { const { _requestingSubtitles } = state['features/subtitles']; const { transcribingEnabled } = state['features/base/config']; - - // Default 'visible' to 'transcribingEnabled' if not explicitly specified - // in the component's properties. const { visible = transcribingEnabled } = ownProps; return {