From b50f858556d6b9e310d345ba26d40b474825e8b8 Mon Sep 17 00:00:00 2001 From: Lyubomir Marinov Date: Fri, 3 Feb 2017 12:51:12 -0600 Subject: [PATCH] [flow] Expand the coverage of flow-monitored files --- react/features/base/connection/functions.js | 4 ++- react/features/base/connection/reducer.js | 36 ++++++++++--------- react/features/base/media/middleware.js | 2 ++ react/features/base/react/RouteRegistry.js | 2 +- react/features/base/tracks/middleware.js | 6 ++-- react/features/base/util/roomnameGenerator.js | 2 +- 6 files changed, 31 insertions(+), 21 deletions(-) diff --git a/react/features/base/connection/functions.js b/react/features/base/connection/functions.js index 292b848e7..b69daa7dc 100644 --- a/react/features/base/connection/functions.js +++ b/react/features/base/connection/functions.js @@ -1,3 +1,5 @@ +/* @flow */ + /** * Returns current domain. * @@ -5,7 +7,7 @@ * state. * @returns {(string|undefined)} */ -export function getDomain(stateOrGetState) { +export function getDomain(stateOrGetState: Function | Object) { const state = typeof stateOrGetState === 'function' ? stateOrGetState() diff --git a/react/features/base/connection/reducer.js b/react/features/base/connection/reducer.js index 1124c26c7..739587dc7 100644 --- a/react/features/base/connection/reducer.js +++ b/react/features/base/connection/reducer.js @@ -1,3 +1,5 @@ +/* @flow */ + import { ReducerRegistry, setStateProperty } from '../redux'; import { @@ -9,20 +11,22 @@ import { /** * Reduces the Redux actions of the feature base/connection. */ -ReducerRegistry.register('features/base/connection', (state = {}, action) => { - switch (action.type) { - case CONNECTION_DISCONNECTED: - return _connectionDisconnected(state, action); +ReducerRegistry.register( + 'features/base/connection', + (state: Object = {}, action: Object) => { + switch (action.type) { + case CONNECTION_DISCONNECTED: + return _connectionDisconnected(state, action); - case CONNECTION_ESTABLISHED: - return _connectionEstablished(state, action); + case CONNECTION_ESTABLISHED: + return _connectionEstablished(state, action); - case SET_DOMAIN: - return _setDomain(state, action); - } + case SET_DOMAIN: + return _setDomain(state, action); + } - return state; -}); + return state; + }); /** * Reduces a specific Redux action CONNECTION_DISCONNECTED of the feature @@ -34,7 +38,7 @@ ReducerRegistry.register('features/base/connection', (state = {}, action) => { * @returns {Object} The new state of the feature base/connection after the * reduction of the specified action. */ -function _connectionDisconnected(state, action) { +function _connectionDisconnected(state: Object, action: Object) { if (state.connection === action.connection) { return setStateProperty(state, 'connection', undefined); } @@ -52,7 +56,7 @@ function _connectionDisconnected(state, action) { * @returns {Object} The new state of the feature base/connection after the * reduction of the specified action. */ -function _connectionEstablished(state, action) { +function _connectionEstablished(state: Object, action: Object) { return setStateProperty(state, 'connection', action.connection); } @@ -65,7 +69,7 @@ function _connectionEstablished(state, action) { * @private * @returns {Object} */ -function _constructConnectionOptions(domain) { +function _constructConnectionOptions(domain: string) { // FIXME The HTTPS scheme for the BOSH URL works with meet.jit.si on both // mobile & Web. It also works with beta.meet.jit.si on Web. Unfortunately, // it doesn't work with beta.meet.jit.si on mobile. Temporarily, use the @@ -89,7 +93,7 @@ function _constructConnectionOptions(domain) { boshProtocol || (boshProtocol = 'https:'); return { - bosh: `${boshProtocol}//${domain}/http-bind`, + bosh: `${String(boshProtocol)}//${domain}/http-bind`, hosts: { domain, focus: `focus.${domain}`, @@ -107,7 +111,7 @@ function _constructConnectionOptions(domain) { * @returns {Object} The new state of the feature base/connection after the * reduction of the specified action. */ -function _setDomain(state, action) { +function _setDomain(state: Object, action: Object) { return { ...state, connectionOptions: { diff --git a/react/features/base/media/middleware.js b/react/features/base/media/middleware.js index 31da9e2b7..605eb0a61 100644 --- a/react/features/base/media/middleware.js +++ b/react/features/base/media/middleware.js @@ -1,3 +1,5 @@ +/* @flow */ + import { CONFERENCE_LEFT } from '../conference'; import { MiddlewareRegistry } from '../redux'; import { setTrackMuted, TRACK_ADDED } from '../tracks'; diff --git a/react/features/base/react/RouteRegistry.js b/react/features/base/react/RouteRegistry.js index b2734801a..58d9b0c3a 100644 --- a/react/features/base/react/RouteRegistry.js +++ b/react/features/base/react/RouteRegistry.js @@ -19,7 +19,7 @@ type Route = { * without needing to create additional inter-feature dependencies. */ class RouteRegistry { - _elements: Route[]; + _elements: Array; /** * Initializes a new RouteRegistry instance. diff --git a/react/features/base/tracks/middleware.js b/react/features/base/tracks/middleware.js index 1338f0d8a..5e4259c11 100644 --- a/react/features/base/tracks/middleware.js +++ b/react/features/base/tracks/middleware.js @@ -1,3 +1,5 @@ +/* @flow */ + import { LIB_DISPOSED, LIB_INITIALIZED } from '../lib-jitsi-meet'; import { MEDIA_TYPE, @@ -67,7 +69,7 @@ MiddlewareRegistry.register(store => next => action => { * @returns {Track} The local Track associated with the specified * mediaType in the specified store. */ -function _getLocalTrack(store, mediaType) { +function _getLocalTrack(store, mediaType: MEDIA_TYPE) { return getLocalTrack(store.getState()['features/base/tracks'], mediaType); } @@ -82,7 +84,7 @@ function _getLocalTrack(store, mediaType) { * @private * @returns {void} */ -function _setMuted(store, action, mediaType) { +function _setMuted(store, action, mediaType: MEDIA_TYPE) { const localTrack = _getLocalTrack(store, mediaType); localTrack && setTrackMuted(localTrack.jitsiTrack, action.muted); diff --git a/react/features/base/util/roomnameGenerator.js b/react/features/base/util/roomnameGenerator.js index 14a8b65aa..1ae9e976a 100644 --- a/react/features/base/util/roomnameGenerator.js +++ b/react/features/base/util/roomnameGenerator.js @@ -152,7 +152,7 @@ const _CONJUNCTION_ = [ * Maps a string (category name) to the array of words from that category. * @const */ -const CATEGORIES = { +const CATEGORIES: { [key: string]: Array } = { _ADJECTIVE_, _ADVERB_, _PLURALNOUN_,