Partially prepare for eslint-plugin-flowtype 2.37.0

This commit is contained in:
Lyubo Marinov 2017-10-03 14:24:00 -05:00
parent 8f97da3265
commit 5561a9c031
10 changed files with 119 additions and 94 deletions

View File

@ -1,3 +1,5 @@
// @flow
import * as JitsiMeetConferenceEvents from '../../ConferenceEvents'; import * as JitsiMeetConferenceEvents from '../../ConferenceEvents';
import { parseJWTFromURLParams } from '../../react/features/jwt'; import { parseJWTFromURLParams } from '../../react/features/jwt';
import { getJitsiMeetTransport } from '../transport'; import { getJitsiMeetTransport } from '../transport';
@ -207,7 +209,10 @@ class API {
* @param {Object} options - Object with the message properties. * @param {Object} options - Object with the message properties.
* @returns {void} * @returns {void}
*/ */
notifyReceivedChatMessage({ body, id, nick, ts } = {}) { notifyReceivedChatMessage(
{ body, id, nick, ts }: {
body: *, id: string, nick: string, ts: *
} = {}) {
if (APP.conference.isLocalId(id)) { if (APP.conference.isLocalId(id)) {
return; return;
} }

View File

@ -1,3 +1,5 @@
// @flow
import { JitsiConferenceEvents } from '../lib-jitsi-meet'; import { JitsiConferenceEvents } from '../lib-jitsi-meet';
import { setAudioMuted, setVideoMuted } from '../media'; import { setAudioMuted, setVideoMuted } from '../media';
import { import {
@ -161,7 +163,7 @@ function _setLocalParticipantData(conference, state) {
* }} * }}
* @public * @public
*/ */
export function conferenceFailed(conference, error) { export function conferenceFailed(conference: Object, error: string) {
return { return {
type: CONFERENCE_FAILED, type: CONFERENCE_FAILED,
conference, conference,
@ -179,7 +181,7 @@ export function conferenceFailed(conference, error) {
* conference: JitsiConference * conference: JitsiConference
* }} * }}
*/ */
export function conferenceJoined(conference) { export function conferenceJoined(conference: Object) {
return { return {
type: CONFERENCE_JOINED, type: CONFERENCE_JOINED,
conference conference
@ -196,7 +198,7 @@ export function conferenceJoined(conference) {
* conference: JitsiConference * conference: JitsiConference
* }} * }}
*/ */
export function conferenceLeft(conference) { export function conferenceLeft(conference: Object) {
return { return {
type: CONFERENCE_LEFT, type: CONFERENCE_LEFT,
conference conference
@ -212,8 +214,8 @@ export function conferenceLeft(conference) {
* local participant will (try to) join. * local participant will (try to) join.
* @returns {Function} * @returns {Function}
*/ */
function _conferenceWillJoin(conference) { function _conferenceWillJoin(conference: Object) {
return (dispatch, getState) => { return (dispatch: Dispatch<*>, getState: Function) => {
const localTracks const localTracks
= getState()['features/base/tracks'] = getState()['features/base/tracks']
.filter(t => t.local) .filter(t => t.local)
@ -243,7 +245,7 @@ function _conferenceWillJoin(conference) {
* conference: JitsiConference * conference: JitsiConference
* }} * }}
*/ */
export function conferenceWillLeave(conference) { export function conferenceWillLeave(conference: Object) {
return { return {
type: CONFERENCE_WILL_LEAVE, type: CONFERENCE_WILL_LEAVE,
conference conference
@ -256,7 +258,7 @@ export function conferenceWillLeave(conference) {
* @returns {Function} * @returns {Function}
*/ */
export function createConference() { export function createConference() {
return (dispatch: Dispatch<*>, getState: Function) => { return (dispatch: Function, getState: Function) => {
const state = getState(); const state = getState();
const { connection, locationURL } = state['features/base/connection']; const { connection, locationURL } = state['features/base/connection'];
@ -331,7 +333,7 @@ export function dataChannelOpened() {
* locked: boolean * locked: boolean
* }} * }}
*/ */
export function lockStateChanged(conference, locked) { export function lockStateChanged(conference: Object, locked: boolean) {
return { return {
type: LOCK_STATE_CHANGED, type: LOCK_STATE_CHANGED,
conference, conference,
@ -348,7 +350,7 @@ export function lockStateChanged(conference, locked) {
* p2p: boolean * p2p: boolean
* }} * }}
*/ */
export function p2pStatusChanged(p2p) { export function p2pStatusChanged(p2p: boolean) {
return { return {
type: P2P_STATUS_CHANGED, type: P2P_STATUS_CHANGED,
p2p p2p
@ -365,7 +367,7 @@ export function p2pStatusChanged(p2p) {
* audioOnly: boolean * audioOnly: boolean
* }} * }}
*/ */
export function setAudioOnly(audioOnly) { export function setAudioOnly(audioOnly: boolean) {
return { return {
type: SET_AUDIO_ONLY, type: SET_AUDIO_ONLY,
audioOnly audioOnly
@ -412,7 +414,10 @@ export function setLastN(lastN: ?number) {
* is to be joined or locked. * is to be joined or locked.
* @returns {Function} * @returns {Function}
*/ */
export function setPassword(conference, method: Function, password: string) { export function setPassword(
conference: Object,
method: Function,
password: string) {
return (dispatch: Dispatch<*>, getState: Function) => { return (dispatch: Dispatch<*>, getState: Function) => {
switch (method) { switch (method) {
case conference.join: { case conference.join: {

View File

@ -1,3 +1,5 @@
// @flow
/** /**
* The {@link RegExp} pattern of the authority of a URI. * The {@link RegExp} pattern of the authority of a URI.
* *
@ -41,7 +43,7 @@ function _fixURIStringHierPart(uri) {
= new RegExp( = new RegExp(
`^${_URI_PROTOCOL_PATTERN}//hipchat\\.com/video/call/`, `^${_URI_PROTOCOL_PATTERN}//hipchat\\.com/video/call/`,
'gi'); 'gi');
let match = regex.exec(uri); let match: Array<string> | null = regex.exec(uri);
if (!match) { if (!match) {
// enso.me // enso.me
@ -80,7 +82,7 @@ function _fixURIStringHierPart(uri) {
*/ */
function _fixURIStringScheme(uri: string) { function _fixURIStringScheme(uri: string) {
const regex = new RegExp(`^${_URI_PROTOCOL_PATTERN}+`, 'gi'); const regex = new RegExp(`^${_URI_PROTOCOL_PATTERN}+`, 'gi');
const match = regex.exec(uri); const match: Array<string> | null = regex.exec(uri);
if (match) { if (match) {
// As an implementation convenience, pick up the last scheme and make // As an implementation convenience, pick up the last scheme and make
@ -115,8 +117,7 @@ function _fixURIStringScheme(uri: string) {
* @returns {string} - The (Web application) context root defined by the * @returns {string} - The (Web application) context root defined by the
* specified {@code location} (URI). * specified {@code location} (URI).
*/ */
export function getLocationContextRoot(location: Object) { export function getLocationContextRoot({ pathname }: { pathname: string }) {
const pathname = location.pathname;
const contextRootEndIndex = pathname.lastIndexOf('/'); const contextRootEndIndex = pathname.lastIndexOf('/');
return ( return (
@ -169,12 +170,12 @@ function _objectToURLParamsArray(obj = {}) {
export function parseStandardURIString(str: string) { export function parseStandardURIString(str: string) {
/* eslint-disable no-param-reassign */ /* eslint-disable no-param-reassign */
const obj = { const obj: Object = {
toString: _standardURIToString toString: _standardURIToString
}; };
let regex; let regex;
let match; let match: Array<string> | null;
// protocol // protocol
regex = new RegExp(`^${_URI_PROTOCOL_PATTERN}`, 'gi'); regex = new RegExp(`^${_URI_PROTOCOL_PATTERN}`, 'gi');
@ -188,7 +189,7 @@ export function parseStandardURIString(str: string) {
regex = new RegExp(`^${_URI_AUTHORITY_PATTERN}`, 'gi'); regex = new RegExp(`^${_URI_AUTHORITY_PATTERN}`, 'gi');
match = regex.exec(str); match = regex.exec(str);
if (match) { if (match) {
let authority = match[1].substring(/* // */ 2); let authority: string = match[1].substring(/* // */ 2);
str = str.substring(regex.lastIndex); str = str.substring(regex.lastIndex);
@ -217,7 +218,7 @@ export function parseStandardURIString(str: string) {
regex = new RegExp(`^${_URI_PATH_PATTERN}`, 'gi'); regex = new RegExp(`^${_URI_PATH_PATTERN}`, 'gi');
match = regex.exec(str); match = regex.exec(str);
let pathname; let pathname: ?string;
if (match) { if (match) {
pathname = match[1]; pathname = match[1];
@ -360,7 +361,7 @@ export function urlObjectToString(o: Object): ?string {
// protocol // protocol
if (!url.protocol) { if (!url.protocol) {
let protocol = o.protocol || o.scheme; let protocol: ?string = o.protocol || o.scheme;
if (protocol) { if (protocol) {
// Protocol is supposed to be the scheme and the final ':'. Anyway, // Protocol is supposed to be the scheme and the final ':'. Anyway,
@ -378,7 +379,7 @@ export function urlObjectToString(o: Object): ?string {
// //
// It may be host/hostname and pathname with the latter denoting the // It may be host/hostname and pathname with the latter denoting the
// tenant. // tenant.
const domain = o.domain || o.host || o.hostname; const domain: ?string = o.domain || o.host || o.hostname;
if (domain) { if (domain) {
const { host, hostname, pathname: contextRoot, port } const { host, hostname, pathname: contextRoot, port }

View File

@ -1,3 +1,5 @@
// @flow
import _ from 'lodash'; import _ from 'lodash';
import JitsiMeetJS from '../base/lib-jitsi-meet'; import JitsiMeetJS from '../base/lib-jitsi-meet';
@ -25,7 +27,7 @@ const statsEmitter = {
* {@code statsEmitter} should subscribe for stat updates. * {@code statsEmitter} should subscribe for stat updates.
* @returns {void} * @returns {void}
*/ */
startListeningForStats(conference) { startListeningForStats(conference: Object) {
const { connectionQuality } = JitsiMeetJS.events; const { connectionQuality } = JitsiMeetJS.events;
conference.on(connectionQuality.LOCAL_STATS_UPDATED, conference.on(connectionQuality.LOCAL_STATS_UPDATED,
@ -44,7 +46,7 @@ const statsEmitter = {
* user have been updated. * user have been updated.
* @returns {void} * @returns {void}
*/ */
subscribeToClientStats(id, callback) { subscribeToClientStats(id: ?string, callback: Function) {
if (!id) { if (!id) {
return; return;
} }
@ -66,7 +68,7 @@ const statsEmitter = {
* stat updates for the specified user id. * stat updates for the specified user id.
* @returns {void} * @returns {void}
*/ */
unsubscribeToClientStats(id, callback) { unsubscribeToClientStats(id: string, callback: Function) {
if (!subscribers[id]) { if (!subscribers[id]) {
return; return;
} }
@ -89,7 +91,7 @@ const statsEmitter = {
* @param {Object} stats - New connection stats for the user. * @param {Object} stats - New connection stats for the user.
* @returns {void} * @returns {void}
*/ */
_emitStatsUpdate(id, stats = {}) { _emitStatsUpdate(id: string, stats: Object = {}) {
const callbacks = subscribers[id] || []; const callbacks = subscribers[id] || [];
callbacks.forEach(callback => { callbacks.forEach(callback => {
@ -107,7 +109,7 @@ const statsEmitter = {
* by the library. * by the library.
* @returns {void} * @returns {void}
*/ */
_onStatsUpdated(currentUserId, stats) { _onStatsUpdated(currentUserId: string, stats: Object) {
const allUserFramerates = stats.framerate || {}; const allUserFramerates = stats.framerate || {};
const allUserResolutions = stats.resolution || {}; const allUserResolutions = stats.resolution || {};

View File

@ -1,17 +1,16 @@
/* global JitsiMeetJS */
import 'aui-css'; import 'aui-css';
import 'aui-experimental-css'; import 'aui-experimental-css';
import DeviceSelectionPopup from './DeviceSelectionPopup'; import DeviceSelectionPopup from './DeviceSelectionPopup';
declare var JitsiMeetJS: Object;
let deviceSelectionPopup; let deviceSelectionPopup;
window.init = function(i18next) { window.init = i18next => {
JitsiMeetJS.init({}).then(() => { JitsiMeetJS.init({}).then(() => {
deviceSelectionPopup = new DeviceSelectionPopup(i18next); deviceSelectionPopup = new DeviceSelectionPopup(i18next);
}); });
}; };
window.addEventListener('beforeunload', () => window.addEventListener('beforeunload', () => deviceSelectionPopup.close());
deviceSelectionPopup.close());

View File

@ -1,3 +1,5 @@
// @flow
import { import {
DIAL_OUT_CANCELED, DIAL_OUT_CANCELED,
DIAL_OUT_CODES_UPDATED, DIAL_OUT_CODES_UPDATED,
@ -25,8 +27,8 @@ export function cancel() {
* @param {string} dialNumber - The number to dial. * @param {string} dialNumber - The number to dial.
* @returns {Function} * @returns {Function}
*/ */
export function dial(dialNumber) { export function dial(dialNumber: string) {
return (dispatch, getState) => { return (dispatch: Dispatch<*>, getState: Function) => {
const { conference } = getState()['features/base/conference']; const { conference } = getState()['features/base/conference'];
conference.dial(dialNumber); conference.dial(dialNumber);
@ -39,8 +41,8 @@ export function dial(dialNumber) {
* @param {string} dialNumber - The dial number to check for validity. * @param {string} dialNumber - The dial number to check for validity.
* @returns {Function} * @returns {Function}
*/ */
export function checkDialNumber(dialNumber) { export function checkDialNumber(dialNumber: string) {
return (dispatch, getState) => { return (dispatch: Dispatch<*>, getState: Function) => {
const { dialOutAuthUrl } = getState()['features/base/config']; const { dialOutAuthUrl } = getState()['features/base/config'];
if (!dialOutAuthUrl) { if (!dialOutAuthUrl) {
@ -78,7 +80,7 @@ export function checkDialNumber(dialNumber) {
* @returns {Function} * @returns {Function}
*/ */
export function updateDialOutCodes() { export function updateDialOutCodes() {
return (dispatch, getState) => { return (dispatch: Dispatch<*>, getState: Function) => {
const { dialOutCodesUrl } = getState()['features/base/config']; const { dialOutCodesUrl } = getState()['features/base/config'];
if (!dialOutCodesUrl) { if (!dialOutCodesUrl) {

View File

@ -1,11 +1,9 @@
import { FEEDBACK_REQUEST_IN_PROGRESS } from '../../../modules/UI/UIErrors'; // @flow
import { openDialog } from '../../features/base/dialog'; import { openDialog } from '../../features/base/dialog';
import { FEEDBACK_REQUEST_IN_PROGRESS } from '../../../modules/UI/UIErrors';
import { import { CANCEL_FEEDBACK, SUBMIT_FEEDBACK } from './actionTypes';
CANCEL_FEEDBACK,
SUBMIT_FEEDBACK
} from './actionTypes';
import { FeedbackDialog } from './components'; import { FeedbackDialog } from './components';
declare var config: Object; declare var config: Object;
@ -23,7 +21,7 @@ declare var interfaceConfig: Object;
* score: number * score: number
* }} * }}
*/ */
export function cancelFeedback(score, message) { export function cancelFeedback(score: number, message: string) {
return { return {
type: CANCEL_FEEDBACK, type: CANCEL_FEEDBACK,
message, message,
@ -42,8 +40,8 @@ export function cancelFeedback(score, message) {
* resolved with true if the dialog is disabled or the feedback was already * resolved with true if the dialog is disabled or the feedback was already
* submitted. Rejected if another dialog is already displayed. * submitted. Rejected if another dialog is already displayed.
*/ */
export function maybeOpenFeedbackDialog(conference) { export function maybeOpenFeedbackDialog(conference: Object) {
return (dispatch, getState) => { return (dispatch: Dispatch<*>, getState: Function) => {
const state = getState(); const state = getState();
if (interfaceConfig.filmStripOnly || config.iAmRecorder) { if (interfaceConfig.filmStripOnly || config.iAmRecorder) {
@ -93,7 +91,7 @@ export function maybeOpenFeedbackDialog(conference) {
* is closed. * is closed.
* @returns {Object} * @returns {Object}
*/ */
export function openFeedbackDialog(conference, onClose) { export function openFeedbackDialog(conference: Object, onClose: ?Function) {
return openDialog(FeedbackDialog, { return openDialog(FeedbackDialog, {
conference, conference,
onClose onClose
@ -113,7 +111,10 @@ export function openFeedbackDialog(conference, onClose) {
* type: SUBMIT_FEEDBACK * type: SUBMIT_FEEDBACK
* }} * }}
*/ */
export function submitFeedback(score, message, conference) { export function submitFeedback(
score: number,
message: string,
conference: Object) {
conference.sendFeedback(score, message); conference.sendFeedback(score, message);
return { return {

View File

@ -1,3 +1,5 @@
// @flow
import { openDialog } from '../../features/base/dialog'; import { openDialog } from '../../features/base/dialog';
import { import {
@ -27,7 +29,7 @@ export function openInviteDialog() {
* visible: boolean * visible: boolean
* }} * }}
*/ */
export function setInfoDialogVisibility(visible) { export function setInfoDialogVisibility(visible: boolean) {
return { return {
type: SET_INFO_DIALOG_VISIBILITY, type: SET_INFO_DIALOG_VISIBILITY,
visible visible
@ -40,7 +42,7 @@ export function setInfoDialogVisibility(visible) {
* @returns {Function} * @returns {Function}
*/ */
export function updateDialInNumbers() { export function updateDialInNumbers() {
return (dispatch, getState) => { return (dispatch: Dispatch<*>, getState: Function) => {
const state = getState(); const state = getState();
const { dialInConfCodeUrl, dialInNumbersUrl, hosts } const { dialInConfCodeUrl, dialInNumbersUrl, hosts }
= state['features/base/config']; = state['features/base/config'];

View File

@ -1,31 +1,18 @@
// @flow
declare var $: Function; declare var $: Function;
declare var interfaceConfig: Object; declare var interfaceConfig: Object;
/** /**
* Sends an ajax request to a directory service. * Get the position of the invite option in the interfaceConfig.INVITE_OPTIONS
* list.
* *
* @param {string} serviceUrl - The service to query. * @param {string} name - The invite option name.
* @param {string} jwt - The jwt token to pass to the search service. * @private
* @param {string} text - Text to search. * @returns {number} - The position of the option in the list.
* @param {Array<string>} queryTypes - Array with the query types that will be
* executed - "conferenceRooms" | "user" | "room".
* @returns {Promise} - The promise created by the request.
*/ */
export function searchPeople( // eslint-disable-line max-params export function getInviteOptionPosition(name: string): number {
serviceUrl, return interfaceConfig.INVITE_OPTIONS.indexOf(name);
jwt,
text,
queryTypes = [ 'conferenceRooms', 'user', 'room' ]) {
const queryTypesString = JSON.stringify(queryTypes);
return new Promise((resolve, reject) => {
$.getJSON(`${serviceUrl}?query=${encodeURIComponent(text)}`
+ `&queryTypes=${queryTypesString}&jwt=${jwt}`,
response => resolve(response)
).fail((jqxhr, textStatus, error) =>
reject(error)
);
});
} }
/** /**
@ -38,17 +25,21 @@ export function searchPeople( // eslint-disable-line max-params
* @param {Immutable.List} people - The list of the "user" type items to invite. * @param {Immutable.List} people - The list of the "user" type items to invite.
* @returns {Promise} - The promise created by the request. * @returns {Promise} - The promise created by the request.
*/ */
export function invitePeople(inviteServiceUrl, inviteUrl, jwt, people) { // eslint-disable-line max-params, max-len export function invitePeople( // eslint-disable-line max-params
inviteServiceUrl: string,
inviteUrl: string,
jwt: string,
people: Object) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
$.post(`${inviteServiceUrl}?token=${jwt}`, $.post(
`${inviteServiceUrl}?token=${jwt}`,
JSON.stringify({ JSON.stringify({
'invited': people, 'invited': people,
'url': inviteUrl }), 'url': inviteUrl
response => resolve(response), }),
resolve,
'json') 'json')
.fail((jqxhr, textStatus, error) => .fail((jqxhr, textStatus, error) => reject(error));
reject(error)
);
}); });
} }
@ -61,10 +52,11 @@ export function invitePeople(inviteServiceUrl, inviteUrl, jwt, people) { // esli
* invite. * invite.
* @returns {void} * @returns {void}
*/ */
export function inviteRooms(conference, rooms) { export function inviteRooms(
conference: { createVideoSIPGWSession: Function },
rooms: Object) {
for (const room of rooms) { for (const room of rooms) {
const sipAddress = room.id; const { id: sipAddress, name: displayName } = room;
const displayName = room.name;
if (sipAddress && displayName) { if (sipAddress && displayName) {
const newSession const newSession
@ -86,18 +78,32 @@ export function inviteRooms(conference, rooms) {
* @returns {boolean} - True to indicate that the given invite option is * @returns {boolean} - True to indicate that the given invite option is
* enabled, false - otherwise. * enabled, false - otherwise.
*/ */
export function isInviteOptionEnabled(name) { export function isInviteOptionEnabled(name: string) {
return interfaceConfig.INVITE_OPTIONS.indexOf(name) !== -1; return getInviteOptionPosition(name) !== -1;
} }
/** /**
* Get the position of the invite option in the interfaceConfig.INVITE_OPTIONS * Sends an ajax request to a directory service.
* list.
* *
* @param {string} optionName - The invite option name. * @param {string} serviceUrl - The service to query.
* @private * @param {string} jwt - The jwt token to pass to the search service.
* @returns {number} - The position of the option in the list. * @param {string} text - Text to search.
* @param {Array<string>} queryTypes - Array with the query types that will be
* executed - "conferenceRooms" | "user" | "room".
* @returns {Promise} - The promise created by the request.
*/ */
export function getInviteOptionPosition(optionName) { export function searchPeople( // eslint-disable-line max-params
return interfaceConfig.INVITE_OPTIONS.indexOf(optionName); serviceUrl: string,
jwt: string,
text: string,
queryTypes: Array<string> = [ 'conferenceRooms', 'user', 'room' ]) {
const queryTypesString = JSON.stringify(queryTypes);
return new Promise((resolve, reject) => {
$.getJSON(
`${serviceUrl}?query=${encodeURIComponent(text)}&queryTypes=${
queryTypesString}&jwt=${jwt}`,
resolve)
.fail((jqxhr, textStatus, error) => reject(error));
});
} }

View File

@ -1,3 +1,5 @@
// @flow
import SideContainerToggler import SideContainerToggler
from '../../../modules/UI/side_pannels/SideContainerToggler'; from '../../../modules/UI/side_pannels/SideContainerToggler';
@ -101,7 +103,7 @@ export function getToolbarClassNames(props: Object) {
* @returns {boolean} - True to indicate that the given toolbar button * @returns {boolean} - True to indicate that the given toolbar button
* is enabled, false - otherwise. * is enabled, false - otherwise.
*/ */
export function isButtonEnabled(name) { export function isButtonEnabled(name: string) {
return interfaceConfig.TOOLBAR_BUTTONS.indexOf(name) !== -1 return interfaceConfig.TOOLBAR_BUTTONS.indexOf(name) !== -1
|| interfaceConfig.MAIN_TOOLBAR_BUTTONS.indexOf(name) !== -1; || interfaceConfig.MAIN_TOOLBAR_BUTTONS.indexOf(name) !== -1;
} }