Consistent naming of functions

Until we make a decision on access modifier hints and adopt a respective
coding style, consistency is king.
This commit is contained in:
Lyubomir Marinov 2017-01-28 17:28:13 -06:00
parent c7c6249ad7
commit 349c04d8d1
12 changed files with 95 additions and 80 deletions

View File

@ -22,19 +22,19 @@ MiddlewareRegistry.register(store => next => action => {
// The react-native module AudioMode is implemented on iOS at the time of // The react-native module AudioMode is implemented on iOS at the time of
// this writing. // this writing.
if (AudioMode) { if (AudioMode) {
let audioMode; let mode;
switch (action.type) { switch (action.type) {
case APP_WILL_MOUNT: case APP_WILL_MOUNT:
case CONFERENCE_FAILED: case CONFERENCE_FAILED:
case CONFERENCE_LEFT: case CONFERENCE_LEFT:
audioMode = AudioMode.DEFAULT; mode = AudioMode.DEFAULT;
break; break;
case CONFERENCE_WILL_JOIN: { case CONFERENCE_WILL_JOIN: {
const conference = store.getState()['features/base/conference']; const conference = store.getState()['features/base/conference'];
audioMode mode
= conference.audioOnly = conference.audioOnly
? AudioMode.AUDIO_CALL ? AudioMode.AUDIO_CALL
: AudioMode.VIDEO_CALL; : AudioMode.VIDEO_CALL;
@ -42,14 +42,14 @@ MiddlewareRegistry.register(store => next => action => {
} }
default: default:
audioMode = null; mode = null;
break; break;
} }
if (audioMode !== null) { if (mode !== null) {
AudioMode.setMode(audioMode).catch(err => { AudioMode.setMode(mode)
console.error(`Failed to set audio mode ${audioMode}: ${err}`); .catch(err =>
}); console.error(`Failed to set audio mode ${mode}: ${err}`));
} }
} }

View File

@ -106,6 +106,7 @@ _RTCPeerConnection.prototype.setRemoteDescription = function(
/** /**
* Logs at error level. * Logs at error level.
* *
* @private
* @returns {void} * @returns {void}
*/ */
function _LOGE(...args) { function _LOGE(...args) {
@ -119,6 +120,8 @@ function _LOGE(...args) {
* *
* @param {RTCSessionDescription} sessionDescription - The RTCSessionDescription * @param {RTCSessionDescription} sessionDescription - The RTCSessionDescription
* which specifies the configuration of the remote end of the connection. * which specifies the configuration of the remote end of the connection.
* @private
* @private
* @returns {Promise} * @returns {Promise}
*/ */
function _setRemoteDescription(sessionDescription) { function _setRemoteDescription(sessionDescription) {
@ -160,6 +163,7 @@ function _setRemoteDescription(sessionDescription) {
* *
* @param {RTCSessionDescription} sdp - The RTCSessionDescription which * @param {RTCSessionDescription} sdp - The RTCSessionDescription which
* specifies the configuration of the remote end of the connection. * specifies the configuration of the remote end of the connection.
* @private
* @returns {Promise} * @returns {Promise}
*/ */
function _synthesizeIPv6Addresses(sdp) { function _synthesizeIPv6Addresses(sdp) {
@ -184,6 +188,7 @@ function _synthesizeIPv6Addresses(sdp) {
* *
* @param {RTCSessionDescription} sessionDescription - The RTCSessionDescription * @param {RTCSessionDescription} sessionDescription - The RTCSessionDescription
* for which IPv6 addresses will be synthesized. * for which IPv6 addresses will be synthesized.
* @private
* @returns {{ * @returns {{
* ips: Map, * ips: Map,
* lines: Array * lines: Array
@ -278,6 +283,7 @@ function _synthesizeIPv6Addresses0(sessionDescription) {
* @param {Map} ips - A Map of IPv4 addresses found in the specified * @param {Map} ips - A Map of IPv4 addresses found in the specified
* sessionDescription to synthesized IPv6 addresses. * sessionDescription to synthesized IPv6 addresses.
* @param {Array} lines - The lines of the specified sessionDescription. * @param {Array} lines - The lines of the specified sessionDescription.
* @private
* @returns {RTCSessionDescription} A RTCSessionDescription that represents the * @returns {RTCSessionDescription} A RTCSessionDescription that represents the
* result of the synthesis of IPv6 addresses. * result of the synthesis of IPv6 addresses.
*/ */

View File

@ -140,9 +140,10 @@ class VideoTrack extends AbstractVideoTrack {
// eslint-disable-next-line valid-jsdoc // eslint-disable-next-line valid-jsdoc
/** /**
* @inheritdoc
*
* Animate the setting of the video track to be rendered by this instance. * Animate the setting of the video track to be rendered by this instance.
*
* @inheritdoc
* @protected
*/ */
_setVideoTrack(videoTrack) { _setVideoTrack(videoTrack) {
// If JitsiTrack instance didn't change, that means some other track's // If JitsiTrack instance didn't change, that means some other track's

View File

@ -21,11 +21,11 @@ MiddlewareRegistry.register(store => next => action => {
switch (action.type) { switch (action.type) {
case CONFERENCE_LEFT: case CONFERENCE_LEFT:
resetInitialMediaState(store); _resetInitialMediaState(store);
break; break;
case TRACK_ADDED: case TRACK_ADDED:
action.track.local && syncTrackMutedState(store, action.track); action.track.local && _syncTrackMutedState(store, action.track);
break; break;
} }
@ -36,9 +36,10 @@ MiddlewareRegistry.register(store => next => action => {
* Resets initial media state. * Resets initial media state.
* *
* @param {Store} store - Redux store. * @param {Store} store - Redux store.
* @private
* @returns {void} * @returns {void}
*/ */
function resetInitialMediaState(store) { function _resetInitialMediaState(store) {
const { dispatch, getState } = store; const { dispatch, getState } = store;
const state = getState()['features/base/media']; const state = getState()['features/base/media'];
@ -53,9 +54,10 @@ function resetInitialMediaState(store) {
* *
* @param {Store} store - Redux store. * @param {Store} store - Redux store.
* @param {Track} track - Local media track. * @param {Track} track - Local media track.
* @private
* @returns {void} * @returns {void}
*/ */
function syncTrackMutedState(store, track) { function _syncTrackMutedState(store, track) {
const state = store.getState()['features/base/media']; const state = store.getState()['features/base/media'];
const muted = state[track.mediaType].muted; const muted = state[track.mediaType].muted;

View File

@ -31,9 +31,10 @@ const AUDIO_INITIAL_MEDIA_STATE = {
* @param {AudioMediaState} state - Media state of local audio. * @param {AudioMediaState} state - Media state of local audio.
* @param {Object} action - Action object. * @param {Object} action - Action object.
* @param {string} action.type - Type of action. * @param {string} action.type - Type of action.
* @private
* @returns {AudioMediaState} * @returns {AudioMediaState}
*/ */
function audio(state = AUDIO_INITIAL_MEDIA_STATE, action) { function _audio(state = AUDIO_INITIAL_MEDIA_STATE, action) {
switch (action.type) { switch (action.type) {
case SET_AUDIO_MUTED: case SET_AUDIO_MUTED:
return { return {
@ -70,9 +71,10 @@ const VIDEO_INITIAL_MEDIA_STATE = {
* @param {VideoMediaState} state - Media state of local video. * @param {VideoMediaState} state - Media state of local video.
* @param {Object} action - Action object. * @param {Object} action - Action object.
* @param {string} action.type - Type of action. * @param {string} action.type - Type of action.
* @private
* @returns {VideoMediaState} * @returns {VideoMediaState}
*/ */
function video(state = VIDEO_INITIAL_MEDIA_STATE, action) { function _video(state = VIDEO_INITIAL_MEDIA_STATE, action) {
switch (action.type) { switch (action.type) {
case SET_CAMERA_FACING_MODE: case SET_CAMERA_FACING_MODE:
return { return {
@ -102,6 +104,6 @@ function video(state = VIDEO_INITIAL_MEDIA_STATE, action) {
* @returns {Object} * @returns {Object}
*/ */
ReducerRegistry.register('features/base/media', combineReducers({ ReducerRegistry.register('features/base/media', combineReducers({
audio, audio: _audio,
video video: _video
})); }));

View File

@ -20,7 +20,7 @@ class RouteRegistry {
* *
* @private * @private
*/ */
this._routeRegistry = new Set(); this._elements = new Set();
} }
/** /**
@ -57,7 +57,7 @@ class RouteRegistry {
// We use the destructuring operator to 'clone' the route object to // We use the destructuring operator to 'clone' the route object to
// prevent modifications from outside (e.g. React Native's Navigator // prevent modifications from outside (e.g. React Native's Navigator
// extends it with additional properties). // extends it with additional properties).
return [ ...this._routeRegistry ].map(r => { return [ ...this._elements ].map(r => {
return { ...r }; return { ...r };
}); });
} }
@ -71,7 +71,7 @@ class RouteRegistry {
*/ */
getRouteByComponent(component) { getRouteByComponent(component) {
const route const route
= [ ...this._routeRegistry ].find(r => r.component === component); = [ ...this._elements ].find(r => r.component === component);
// We use destructuring operator to 'clone' route object to prevent // We use destructuring operator to 'clone' route object to prevent
// modifications from outside (e.g. React Native's Navigator extends // modifications from outside (e.g. React Native's Navigator extends
@ -86,11 +86,11 @@ class RouteRegistry {
* @returns {void} * @returns {void}
*/ */
register(route) { register(route) {
if (this._routeRegistry.has(route)) { if (this._elements.has(route)) {
throw new Error(`Route ${route.component} is registered already!`); throw new Error(`Route ${route.component} is registered already!`);
} }
this._routeRegistry.add(route); this._elements.add(route);
} }
} }

View File

@ -48,9 +48,10 @@ const PARTICIPANT_PROPS_TO_OMIT_WHEN_UPDATE
* @param {Participant} action.participant - Information about participant to be * @param {Participant} action.participant - Information about participant to be
* added/modified. * added/modified.
* @param {JitsiConference} action.conference - Conference instance. * @param {JitsiConference} action.conference - Conference instance.
* @private
* @returns {Participant|undefined} * @returns {Participant|undefined}
*/ */
function participant(state, action) { function _participant(state, action) {
switch (action.type) { switch (action.type) {
case DOMINANT_SPEAKER_CHANGED: case DOMINANT_SPEAKER_CHANGED:
// Only one dominant speaker is allowed. // Only one dominant speaker is allowed.
@ -146,7 +147,7 @@ function participant(state, action) {
ReducerRegistry.register('features/base/participants', (state = [], action) => { ReducerRegistry.register('features/base/participants', (state = [], action) => {
switch (action.type) { switch (action.type) {
case PARTICIPANT_JOINED: case PARTICIPANT_JOINED:
return [ ...state, participant(undefined, action) ]; return [ ...state, _participant(undefined, action) ];
case PARTICIPANT_LEFT: case PARTICIPANT_LEFT:
return state.filter(p => p.id !== action.participant.id); return state.filter(p => p.id !== action.participant.id);
@ -155,7 +156,7 @@ ReducerRegistry.register('features/base/participants', (state = [], action) => {
case PARTICIPANT_ID_CHANGED: case PARTICIPANT_ID_CHANGED:
case PARTICIPANT_UPDATED: case PARTICIPANT_UPDATED:
case PIN_PARTICIPANT: case PIN_PARTICIPANT:
return state.map(p => participant(p, action)); return state.map(p => _participant(p, action));
default: default:
return state; return state;

View File

@ -12,7 +12,7 @@ class MiddlewareRegistry {
/** /**
* The set of registered middleware. * The set of registered middleware.
*/ */
this.middlewareRegistry = new Set(); this._elements = new Set();
} }
/** /**
@ -25,7 +25,7 @@ class MiddlewareRegistry {
*/ */
applyMiddleware(...additional) { applyMiddleware(...additional) {
return applyMiddleware( return applyMiddleware(
...this.middlewareRegistry, ...this._elements,
...additional ...additional
); );
} }
@ -39,7 +39,7 @@ class MiddlewareRegistry {
* @returns {void} * @returns {void}
*/ */
register(middleware) { register(middleware) {
this.middlewareRegistry.add(middleware); this._elements.add(middleware);
} }
} }

View File

@ -13,7 +13,7 @@ class ReducerRegistry {
* The set of registered reducers, keyed based on the field each reducer * The set of registered reducers, keyed based on the field each reducer
* will manage. * will manage.
*/ */
this.reducerRegistry = {}; this._elements = {};
} }
/** /**
@ -25,7 +25,7 @@ class ReducerRegistry {
*/ */
combineReducers(additional = {}) { combineReducers(additional = {}) {
return combineReducers({ return combineReducers({
...this.reducerRegistry, ...this._elements,
...additional ...additional
}); });
} }
@ -41,7 +41,7 @@ class ReducerRegistry {
* @returns {void} * @returns {void}
*/ */
register(name, reducer) { register(name, reducer) {
this.reducerRegistry[name] = reducer; this._elements[name] = reducer;
} }
} }

View File

@ -53,39 +53,6 @@ export function destroyLocalTracks() {
.map(t => t.jitsiTrack))); .map(t => t.jitsiTrack)));
} }
/**
* Returns true if the provided JitsiTrack should be rendered as a mirror.
*
* We only want to show a video in mirrored mode when:
* 1) The video source is local, and not remote.
* 2) The video source is a camera, not a desktop (capture).
* 3) The camera is capturing the user, not the environment.
*
* TODO Similar functionality is part of lib-jitsi-meet. This function should be
* removed after https://github.com/jitsi/lib-jitsi-meet/pull/187 is merged.
*
* @param {(JitsiLocalTrack|JitsiRemoteTrack)} track - JitsiTrack instance.
* @private
* @returns {boolean}
*/
function _shouldMirror(track) {
return (
track
&& track.isLocal()
&& track.isVideoTrack()
// XXX Type of the return value of
// JitsiLocalTrack#getCameraFacingMode() happens to be named
// CAMERA_FACING_MODE as well, it's defined by lib-jitsi-meet. Note
// though that the type of the value on the right side of the
// equality check is defined by jitsi-meet-react. The type
// definitions are surely compatible today but that may not be the
// case tomorrow.
&& track.getCameraFacingMode() === CAMERA_FACING_MODE.USER
&& !track.isScreenSharing()
);
}
/** /**
* Create an action for when a new track has been signaled to be added to the * Create an action for when a new track has been signaled to be added to the
* conference. * conference.
@ -240,6 +207,7 @@ function _disposeAndRemoveTracks(tracks) {
* through. * through.
* @param {MEDIA_TYPE} mediaType - The <tt>MEDIA_TYPE</tt> of the first * @param {MEDIA_TYPE} mediaType - The <tt>MEDIA_TYPE</tt> of the first
* <tt>JitsiLocalTrack</tt> to be returned. * <tt>JitsiLocalTrack</tt> to be returned.
* @private
* @returns {JitsiLocalTrack} The first <tt>JitsiLocalTrack</tt>, if any, in the * @returns {JitsiLocalTrack} The first <tt>JitsiLocalTrack</tt>, if any, in the
* specified <tt>tracks</tt> of the specified <tt>mediaType</tt>. * specified <tt>tracks</tt> of the specified <tt>mediaType</tt>.
*/ */
@ -287,12 +255,46 @@ function _getLocalTracksToChange(currentTracks, newTracks) {
}; };
} }
/**
* Returns true if the provided JitsiTrack should be rendered as a mirror.
*
* We only want to show a video in mirrored mode when:
* 1) The video source is local, and not remote.
* 2) The video source is a camera, not a desktop (capture).
* 3) The camera is capturing the user, not the environment.
*
* TODO Similar functionality is part of lib-jitsi-meet. This function should be
* removed after https://github.com/jitsi/lib-jitsi-meet/pull/187 is merged.
*
* @param {(JitsiLocalTrack|JitsiRemoteTrack)} track - JitsiTrack instance.
* @private
* @returns {boolean}
*/
function _shouldMirror(track) {
return (
track
&& track.isLocal()
&& track.isVideoTrack()
// XXX Type of the return value of
// JitsiLocalTrack#getCameraFacingMode() happens to be named
// CAMERA_FACING_MODE as well, it's defined by lib-jitsi-meet. Note
// though that the type of the value on the right side of the
// equality check is defined by jitsi-meet-react. The type
// definitions are surely compatible today but that may not be the
// case tomorrow.
&& track.getCameraFacingMode() === CAMERA_FACING_MODE.USER
&& !track.isScreenSharing()
);
}
/** /**
* Set new local tracks replacing any existing tracks that were previously * Set new local tracks replacing any existing tracks that were previously
* available. Currently only one audio and one video local tracks are allowed. * available. Currently only one audio and one video local tracks are allowed.
* *
* @param {(JitsiLocalTrack|JitsiRemoteTrack)[]} [newTracks=[]] - List of new * @param {(JitsiLocalTrack|JitsiRemoteTrack)[]} [newTracks=[]] - List of new
* media tracks. * media tracks.
* @private
* @returns {Function} * @returns {Function}
*/ */
function _updateLocalTracks(newTracks = []) { function _updateLocalTracks(newTracks = []) {

View File

@ -45,18 +45,6 @@ class Thumbnail extends Component {
this._onClick = this._onClick.bind(this); this._onClick = this._onClick.bind(this);
} }
/**
* Handles click/tap event on the thumbnail.
*
* @returns {void}
*/
_onClick() {
const { dispatch, participant } = this.props;
// TODO The following currently ignores interfaceConfig.filmStripOnly.
dispatch(pinParticipant(participant.pinned ? null : participant.id));
}
/** /**
* Implements React's {@link Component#render()}. * Implements React's {@link Component#render()}.
* *
@ -126,6 +114,18 @@ class Thumbnail extends Component {
</Container> </Container>
); );
} }
/**
* Handles click/tap event on the thumbnail.
*
* @returns {void}
*/
_onClick() {
const { dispatch, participant } = this.props;
// TODO The following currently ignores interfaceConfig.filmStripOnly.
dispatch(pinParticipant(participant.pinned ? null : participant.id));
}
} }
/** /**

View File

@ -22,14 +22,14 @@ MiddlewareRegistry.register(store => next => action => {
// TODO(saghul): Implement audio-only mode. // TODO(saghul): Implement audio-only mode.
if (!state.audioOnly) { if (!state.audioOnly) {
setWakeLock(true); _setWakeLock(true);
} }
break; break;
} }
case CONFERENCE_FAILED: case CONFERENCE_FAILED:
case CONFERENCE_LEFT: case CONFERENCE_LEFT:
setWakeLock(false); _setWakeLock(false);
break; break;
} }
@ -42,9 +42,10 @@ MiddlewareRegistry.register(store => next => action => {
* *
* @param {boolean} wakeLock - True to active the wake lock or false to * @param {boolean} wakeLock - True to active the wake lock or false to
* deactivate it. * deactivate it.
* @private
* @returns {void} * @returns {void}
*/ */
function setWakeLock(wakeLock) { function _setWakeLock(wakeLock) {
if (wakeLock) { if (wakeLock) {
KeepAwake.activate(); KeepAwake.activate();
} else { } else {