Coding style: consistency, jsdocs

These modification are not necessarily directly related to the
containing PR, I merely saw them while reviewing the containing PR.
This commit is contained in:
Lyubo Marinov 2017-11-27 16:08:12 -06:00
parent 38629b437d
commit d1e5e6b93b
12 changed files with 103 additions and 126 deletions

View File

@ -1,4 +1,4 @@
/* @flow */ // @flow
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import React, { Component } from 'react'; import React, { Component } from 'react';
@ -22,6 +22,27 @@ declare var interfaceConfig: Object;
* @extends Component * @extends Component
*/ */
class CallOverlay extends Component<*, *> { class CallOverlay extends Component<*, *> {
/**
* {@code CallOverlay} component's property types.
*
* @static
*/
static propTypes = {
_callee: PropTypes.object
};
/**
* Determines whether this overlay needs to be rendered (according to a
* specific redux state). Called by {@link OverlayContainer}.
*
* @param {Object} state - The redux state.
* @returns {boolean} - If this overlay needs to be rendered, {@code true};
* {@code false}, otherwise.
*/
static needsRender(state) {
return state['features/base/jwt'].callOverlayVisible;
}
/** /**
* The (reference to the) {@link Audio} which plays/renders the audio * The (reference to the) {@link Audio} which plays/renders the audio
* depicting the ringing phase of the call establishment represented by this * depicting the ringing phase of the call establishment represented by this
@ -68,27 +89,6 @@ class CallOverlay extends Component<*, *> {
ringing: boolean ringing: boolean
} }
/**
* {@code CallOverlay} component's property types.
*
* @static
*/
static propTypes = {
_callee: PropTypes.object
};
/**
* Check if this overlay needs to be rendered. This function will be called
* by the {@code OverlayContainer}.
*
* @param {Object} state - The redux state.
* @returns {boolean} - True if this overlay needs to be rendered, false
* otherwise.
*/
static needsRender(state) {
return state['features/base/jwt'].callOverlayVisible;
}
/** /**
* Initializes a new {@code CallOverlay} instance. * Initializes a new {@code CallOverlay} instance.
* *

View File

@ -1,8 +1,8 @@
/* @flow */ // @flow
import { setConfigFromURLParams } from '../../base/config'; import { setConfigFromURLParams } from '../config';
import { toState } from '../../base/redux'; import { toState } from '../redux';
import { loadScript } from '../../base/util'; import { loadScript } from '../util';
import JitsiMeetJS from './_'; import JitsiMeetJS from './_';
@ -54,17 +54,18 @@ export function isAnalyticsEnabled(stateful: Function | Object) {
} }
/** /**
* Determines whether a specific JitsiConferenceErrors instance indicates a * Determines whether a specific {@link JitsiConferenceErrors} instance
* fatal JitsiConference error. * indicates a fatal {@link JitsiConference} error.
* *
* FIXME Figure out the category of errors defined by the function and describe * FIXME Figure out the category of errors defined by the function and describe
* that category. I've currently named the category fatal because it appears to * that category. I've currently named the category fatal because it appears to
* be used in the cases of unrecoverable errors that necessitate a reload. * be used in the cases of unrecoverable errors that necessitate a reload.
* *
* @param {Object|string} error - The JitsiConferenceErrors instance to * @param {Object|string} error - The {@code JitsiConferenceErrors} instance to
* categorize/classify or an Error-like object. * categorize/classify or an {@link Error}-like object.
* @returns {boolean} True if the specified JitsiConferenceErrors instance * @returns {boolean} If the specified {@code JitsiConferenceErrors} instance
* indicates a fatal JitsiConference error; otherwise, false. * indicates a fatal {@code JitsiConference} error, {@code true}; otherwise,
* {@code false}.
*/ */
export function isFatalJitsiConferenceError(error: Object | string) { export function isFatalJitsiConferenceError(error: Object | string) {
if (typeof error !== 'string') { if (typeof error !== 'string') {
@ -78,17 +79,18 @@ export function isFatalJitsiConferenceError(error: Object | string) {
} }
/** /**
* Determines whether a specific JitsiConnectionErrors instance indicates a * Determines whether a specific {@link JitsiConnectionErrors} instance
* fatal JitsiConnection error. * indicates a fatal {@link JitsiConnection} error.
* *
* FIXME Figure out the category of errors defined by the function and describe * FIXME Figure out the category of errors defined by the function and describe
* that category. I've currently named the category fatal because it appears to * that category. I've currently named the category fatal because it appears to
* be used in the cases of unrecoverable errors that necessitate a reload. * be used in the cases of unrecoverable errors that necessitate a reload.
* *
* @param {Object|string} error - The JitsiConnectionErrors instance to * @param {Object|string} error - The {@code JitsiConnectionErrors} instance to
* categorize/classify or an Error-like object. * categorize/classify or an {@link Error}-like object.
* @returns {boolean} True if the specified JitsiConnectionErrors instance * @returns {boolean} If the specified {@code JitsiConnectionErrors} instance
* indicates a fatal JitsiConnection error; otherwise, false. * indicates a fatal {@code JitsiConnection} error, {@code true}; otherwise,
* {@code false}.
*/ */
export function isFatalJitsiConnectionError(error: Object | string) { export function isFatalJitsiConnectionError(error: Object | string) {
if (typeof error !== 'string') { if (typeof error !== 'string') {

View File

@ -1,4 +1,4 @@
/* @flow */ // @flow
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import React, { Component } from 'react'; import React, { Component } from 'react';
@ -17,11 +17,11 @@ declare var APP: Object;
const logger = require('jitsi-meet-logger').getLogger(__filename); const logger = require('jitsi-meet-logger').getLogger(__filename);
/** /**
* Implements abstract React Component for the page reload overlays. * Implements an abstract React {@link Component} for the page reload overlays.
*/ */
export default class AbstractPageReloadOverlay extends Component<*, *> { export default class AbstractPageReloadOverlay extends Component<*, *> {
/** /**
* AbstractPageReloadOverlay component's property types. * {@code AbstractPageReloadOverlay} component's property types.
* *
* @static * @static
*/ */
@ -55,6 +55,25 @@ export default class AbstractPageReloadOverlay extends Component<*, *> {
t: PropTypes.func t: PropTypes.func
}; };
/**
* Determines whether this overlay needs to be rendered (according to a
* specific redux state). Called by {@link OverlayContainer}.
*
* @param {Object} state - The redux state.
* @returns {boolean} - If this overlay needs to be rendered, {@code true};
* {@code false}, otherwise.
*/
static needsRender(state) {
const conferenceError = state['features/base/conference'].error;
const connectionError = state['features/base/connection'].error;
return (
(connectionError && isFatalJitsiConnectionError(connectionError))
|| (conferenceError
&& isFatalJitsiConferenceError(conferenceError))
);
}
_interval: ?number _interval: ?number
state: { state: {
@ -89,25 +108,6 @@ export default class AbstractPageReloadOverlay extends Component<*, *> {
title: string title: string
} }
/**
* Check if this overlay needs to be rendered. This function will be called
* by the {@code OverlayContainer}.
*
* @param {Object} state - The redux state.
* @returns {boolean} - True if this overlay needs to be rendered, false
* otherwise.
*/
static needsRender(state) {
const conferenceError = state['features/base/conference'].error;
const connectionError = state['features/base/connection'].error;
return (
(connectionError && isFatalJitsiConnectionError(connectionError))
|| (conferenceError
&& isFatalJitsiConferenceError(conferenceError))
);
}
/** /**
* Initializes a new AbstractPageReloadOverlay instance. * Initializes a new AbstractPageReloadOverlay instance.
* *
@ -220,10 +220,10 @@ export default class AbstractPageReloadOverlay extends Component<*, *> {
* @returns {ReactElement} * @returns {ReactElement}
*/ */
_renderProgressBar() { _renderProgressBar() {
const { timeoutSeconds, timeLeft } = this.state; const { timeLeft, timeoutSeconds } = this.state;
const timeRemaining = timeoutSeconds - timeLeft; const timeRemaining = timeoutSeconds - timeLeft;
const percentageComplete = Math.floor( const percentageComplete
(timeRemaining / timeoutSeconds) * 100); = Math.floor((timeRemaining / timeoutSeconds) * 100);
return ( return (
<div <div
@ -231,9 +231,7 @@ export default class AbstractPageReloadOverlay extends Component<*, *> {
id = 'reloadProgressBar'> id = 'reloadProgressBar'>
<div <div
className = 'progress-indicator-fill' className = 'progress-indicator-fill'
style = {{ style = {{ width: `${percentageComplete}%` }} />
width: `${percentageComplete}%`
}} />
</div> </div>
); );
} }
@ -243,11 +241,11 @@ export default class AbstractPageReloadOverlay extends Component<*, *> {
* Maps (parts of) the redux state to the associated component's props. * Maps (parts of) the redux state to the associated component's props.
* *
* @param {Object} state - The redux state. * @param {Object} state - The redux state.
* @returns {{
* isNetworkFailure: boolean,
* reason: string
* }}
* @protected * @protected
* @returns {{
* isNetworkFailure: boolean,
* reason: string
* }}
*/ */
export function abstractMapStateToProps(state: Object) { export function abstractMapStateToProps(state: Object) {
const conferenceError = state['features/base/conference'].error; const conferenceError = state['features/base/conference'].error;

View File

@ -2,12 +2,12 @@ import PropTypes from 'prop-types';
import { Component } from 'react'; import { Component } from 'react';
/** /**
* Implements a React Component for suspended overlay. Shown when a suspend is * Implements a React {@link Component} for suspended overlay. Shown when a
* detected. * suspend is detected.
*/ */
export default class AbstractSuspendedOverlay extends Component { export default class AbstractSuspendedOverlay extends Component {
/** /**
* SuspendedOverlay component's property types. * {@code AbstractSuspendedOverlay} component's property types.
* *
* @static * @static
*/ */
@ -22,24 +22,14 @@ export default class AbstractSuspendedOverlay extends Component {
}; };
/** /**
* Check if this overlay needs to be rendered. This function will be called * Determines whether this overlay needs to be rendered (according to a
* by the {@code OverlayContainer}. * specific redux state). Called by {@link OverlayContainer}.
* *
* @param {Object} state - The redux state. * @param {Object} state - The redux state.
* @returns {boolean} - True if this overlay needs to be rendered, false * @returns {boolean} - If this overlay needs to be rendered, {@code true};
* otherwise. * {@code false}, otherwise.
*/ */
static needsRender(state) { static needsRender(state) {
return state['features/overlay'].suspendDetected; return state['features/overlay'].suspendDetected;
} }
/**
* Implements React's {@link Component#render()}.
*
* @inheritdoc
* @returns {ReactElement|null}
*/
render() {
return null;
}
} }

View File

@ -1,14 +1,13 @@
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { Component } from 'react'; import { Component } from 'react';
/** /**
* Implements a React Component for overlay with guidance how to proceed with * Implements a React {@link Component} for overlay with guidance how to proceed
* gUM prompt. * with gUM prompt.
*/ */
export default class AbstractUserMediaPermissionsOverlay extends Component { export default class AbstractUserMediaPermissionsOverlay extends Component {
/** /**
* UserMediaPermissionsOverlay component's property types. * {@code AbstractUserMediaPermissionsOverlay} component's property types.
* *
* @static * @static
*/ */
@ -32,36 +31,26 @@ export default class AbstractUserMediaPermissionsOverlay extends Component {
}; };
/** /**
* Check if this overlay needs to be rendered. This function will be called * Determines whether this overlay needs to be rendered (according to a
* by the {@code OverlayContainer}. * specific redux state). Called by {@link OverlayContainer}.
* *
* @param {Object} state - The redux state. * @param {Object} state - The redux state.
* @returns {boolean} - True if this overlay needs to be rendered, false * @returns {boolean} - If this overlay needs to be rendered, {@code true};
* otherwise. * {@code false}, otherwise.
*/ */
static needsRender(state) { static needsRender(state) {
return state['features/overlay'].isMediaPermissionPromptVisible; return state['features/overlay'].isMediaPermissionPromptVisible;
} }
/**
* Implements React's {@link Component#render()}.
*
* @inheritdoc
* @returns {ReactElement|null}
*/
render() {
return null;
}
} }
/** /**
* Maps (parts of) the redux state to the associated component's props. * Maps (parts of) the redux state to the associated component's props.
* *
* @param {Object} state - The redux state. * @param {Object} state - The redux state.
* @returns {{
* browser: string
* }}
* @protected * @protected
* @returns {{
* browser: string
* }}
*/ */
export function abstractMapStateToProps(state) { export function abstractMapStateToProps(state) {
const { browser } = state['features/overlay']; const { browser } = state['features/overlay'];

View File

@ -82,7 +82,7 @@ class FilmstripOnlyOverlayFrame extends Component {
* Implements React's {@link Component#render()}. * Implements React's {@link Component#render()}.
* *
* @inheritdoc * @inheritdoc
* @returns {ReactElement|null} * @returns {ReactElement}
*/ */
render() { render() {
return ( return (

View File

@ -51,8 +51,8 @@ function getOverlays() {
} }
/** /**
* Implements a React Component that will display the correct overlay when * Implements a React {@link Component} that will display the correct overlay
* needed. * when needed.
*/ */
class OverlayContainer extends Component { class OverlayContainer extends Component {
/** /**
@ -71,8 +71,8 @@ class OverlayContainer extends Component {
* Implements React's {@link Component#render()}. * Implements React's {@link Component#render()}.
* *
* @inheritdoc * @inheritdoc
* @returns {ReactElement|null}
* @public * @public
* @returns {ReactElement|null}
*/ */
render() { render() {
const { overlay } = this.props; const { overlay } = this.props;
@ -82,13 +82,14 @@ class OverlayContainer extends Component {
} }
/** /**
* Maps (parts of) the redux state to the associated OverlayContainer's props. * Maps (parts of) the redux state to the associated {@code OverlayContainer}'s
* props.
* *
* @param {Object} state - The redux state. * @param {Object} state - The redux state.
* @returns {{
* overlay: ?Object
* }}
* @private * @private
* @returns {{
* overlay: ?Object
* }}
*/ */
function _mapStateToProps(state) { function _mapStateToProps(state) {
let overlay; let overlay;

View File

@ -4,7 +4,7 @@ import PropTypes from 'prop-types';
import React, { Component } from 'react'; import React, { Component } from 'react';
/** /**
* Implements a React Component for the frame of the overlays. * Implements a React {@link Component} for the frame of the overlays.
*/ */
export default class OverlayFrame extends Component { export default class OverlayFrame extends Component {
/** /**

View File

@ -15,8 +15,7 @@ class SuspendedFilmstripOnlyOverlay extends AbstractSuspendedOverlay {
* Implements React's {@link Component#render()}. * Implements React's {@link Component#render()}.
* *
* @inheritdoc * @inheritdoc
* @override * @returns {ReactElement}
* @returns {ReactElement|null}
*/ */
render() { render() {
const { t } = this.props; const { t } = this.props;

View File

@ -15,8 +15,7 @@ class SuspendedOverlay extends AbstractSuspendedOverlay {
* Implements React's {@link Component#render()}. * Implements React's {@link Component#render()}.
* *
* @inheritdoc * @inheritdoc
* @override * @returns {ReactElement}
* @returns {ReactElement|null}
*/ */
render() { render() {
const { t } = this.props; const { t } = this.props;

View File

@ -13,12 +13,12 @@ import FilmstripOnlyOverlayFrame from './FilmstripOnlyOverlayFrame';
*/ */
class UserMediaPermissionsFilmstripOnlyOverlay class UserMediaPermissionsFilmstripOnlyOverlay
extends AbstractUserMediaPermissionsOverlay { extends AbstractUserMediaPermissionsOverlay {
/** /**
* Implements React's {@link Component#render()}. * Implements React's {@link Component#render()}.
* *
* @inheritdoc * @inheritdoc
* @override * @returns {ReactElement}
* @returns {ReactElement|null}
*/ */
render() { render() {
const { t } = this.props; const { t } = this.props;

View File

@ -38,8 +38,7 @@ class UserMediaPermissionsOverlay extends AbstractUserMediaPermissionsOverlay {
* Implements React's {@link Component#render()}. * Implements React's {@link Component#render()}.
* *
* @inheritdoc * @inheritdoc
* @override * @returns {ReactElement}
* @returns {ReactElement|null}
*/ */
render() { render() {
const { browser, t } = this.props; const { browser, t } = this.props;
@ -77,8 +76,8 @@ class UserMediaPermissionsOverlay extends AbstractUserMediaPermissionsOverlay {
/** /**
* Renders the policy logo. * Renders the policy logo.
* *
* @returns {ReactElement|null}
* @private * @private
* @returns {ReactElement|null}
*/ */
_renderPolicyLogo() { _renderPolicyLogo() {
const { policyLogoSrc } = this.state; const { policyLogoSrc } = this.state;