Partially prepare for eslint-plugin-flowtype 2.37.0

pull/2030/head
Lyubo Marinov 7 years ago
parent 8f97da3265
commit 5561a9c031
  1. 7
      modules/API/API.js
  2. 27
      react/features/base/conference/actions.js
  3. 21
      react/features/base/util/uri.js
  4. 12
      react/features/connection-indicator/statsEmitter.js
  5. 9
      react/features/device-selection/popup.js
  6. 12
      react/features/dial-out/actions.js
  7. 21
      react/features/feedback/actions.js
  8. 6
      react/features/invite/actions.js
  9. 94
      react/features/invite/functions.js
  10. 4
      react/features/toolbox/functions.web.js

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

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

@ -1,3 +1,5 @@
// @flow
/**
* The {@link RegExp} pattern of the authority of a URI.
*
@ -41,7 +43,7 @@ function _fixURIStringHierPart(uri) {
= new RegExp(
`^${_URI_PROTOCOL_PATTERN}//hipchat\\.com/video/call/`,
'gi');
let match = regex.exec(uri);
let match: Array<string> | null = regex.exec(uri);
if (!match) {
// enso.me
@ -80,7 +82,7 @@ function _fixURIStringHierPart(uri) {
*/
function _fixURIStringScheme(uri: string) {
const regex = new RegExp(`^${_URI_PROTOCOL_PATTERN}+`, 'gi');
const match = regex.exec(uri);
const match: Array<string> | null = regex.exec(uri);
if (match) {
// 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
* specified {@code location} (URI).
*/
export function getLocationContextRoot(location: Object) {
const pathname = location.pathname;
export function getLocationContextRoot({ pathname }: { pathname: string }) {
const contextRootEndIndex = pathname.lastIndexOf('/');
return (
@ -169,12 +170,12 @@ function _objectToURLParamsArray(obj = {}) {
export function parseStandardURIString(str: string) {
/* eslint-disable no-param-reassign */
const obj = {
const obj: Object = {
toString: _standardURIToString
};
let regex;
let match;
let match: Array<string> | null;
// protocol
regex = new RegExp(`^${_URI_PROTOCOL_PATTERN}`, 'gi');
@ -188,7 +189,7 @@ export function parseStandardURIString(str: string) {
regex = new RegExp(`^${_URI_AUTHORITY_PATTERN}`, 'gi');
match = regex.exec(str);
if (match) {
let authority = match[1].substring(/* // */ 2);
let authority: string = match[1].substring(/* // */ 2);
str = str.substring(regex.lastIndex);
@ -217,7 +218,7 @@ export function parseStandardURIString(str: string) {
regex = new RegExp(`^${_URI_PATH_PATTERN}`, 'gi');
match = regex.exec(str);
let pathname;
let pathname: ?string;
if (match) {
pathname = match[1];
@ -360,7 +361,7 @@ export function urlObjectToString(o: Object): ?string {
// protocol
if (!url.protocol) {
let protocol = o.protocol || o.scheme;
let protocol: ?string = o.protocol || o.scheme;
if (protocol) {
// 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
// tenant.
const domain = o.domain || o.host || o.hostname;
const domain: ?string = o.domain || o.host || o.hostname;
if (domain) {
const { host, hostname, pathname: contextRoot, port }

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

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

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

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

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

@ -1,31 +1,18 @@
// @flow
declare var $: Function;
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} jwt - The jwt token to pass to the search service.
* @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.
* @param {string} name - The invite option name.
* @private
* @returns {number} - The position of the option in the list.
*/
export function searchPeople( // eslint-disable-line max-params
serviceUrl,
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)
);
});
export function getInviteOptionPosition(name: string): number {
return interfaceConfig.INVITE_OPTIONS.indexOf(name);
}
/**
@ -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.
* @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) => {
$.post(`${inviteServiceUrl}?token=${jwt}`,
JSON.stringify({
'invited': people,
'url': inviteUrl }),
response => resolve(response),
'json')
.fail((jqxhr, textStatus, error) =>
reject(error)
);
$.post(
`${inviteServiceUrl}?token=${jwt}`,
JSON.stringify({
'invited': people,
'url': inviteUrl
}),
resolve,
'json')
.fail((jqxhr, textStatus, error) => reject(error));
});
}
@ -61,10 +52,11 @@ export function invitePeople(inviteServiceUrl, inviteUrl, jwt, people) { // esli
* invite.
* @returns {void}
*/
export function inviteRooms(conference, rooms) {
export function inviteRooms(
conference: { createVideoSIPGWSession: Function },
rooms: Object) {
for (const room of rooms) {
const sipAddress = room.id;
const displayName = room.name;
const { id: sipAddress, name: displayName } = room;
if (sipAddress && displayName) {
const newSession
@ -86,18 +78,32 @@ export function inviteRooms(conference, rooms) {
* @returns {boolean} - True to indicate that the given invite option is
* enabled, false - otherwise.
*/
export function isInviteOptionEnabled(name) {
return interfaceConfig.INVITE_OPTIONS.indexOf(name) !== -1;
export function isInviteOptionEnabled(name: string) {
return getInviteOptionPosition(name) !== -1;
}
/**
* Get the position of the invite option in the interfaceConfig.INVITE_OPTIONS
* list.
* Sends an ajax request to a directory service.
*
* @param {string} optionName - The invite option name.
* @private
* @returns {number} - The position of the option in the list.
* @param {string} serviceUrl - The service to query.
* @param {string} jwt - The jwt token to pass to the search service.
* @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) {
return interfaceConfig.INVITE_OPTIONS.indexOf(optionName);
export function searchPeople( // eslint-disable-line max-params
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));
});
}

@ -1,3 +1,5 @@
// @flow
import 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
* is enabled, false - otherwise.
*/
export function isButtonEnabled(name) {
export function isButtonEnabled(name: string) {
return interfaceConfig.TOOLBAR_BUTTONS.indexOf(name) !== -1
|| interfaceConfig.MAIN_TOOLBAR_BUTTONS.indexOf(name) !== -1;
}

Loading…
Cancel
Save