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 = ...; }`.
This commit is contained in:
parent
ee9f304345
commit
1d128e027a
|
@ -86,10 +86,9 @@ export default class AbstractDialog<P : Props, S : State>
|
|||
* @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<P : Props, S : State>
|
|||
* @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.
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue