From a14886031ffe4d6dc3dab05eff01a4caf8bac46f Mon Sep 17 00:00:00 2001 From: Leonard Kim Date: Fri, 19 May 2017 15:35:10 -0700 Subject: [PATCH] SQUASH: changes based on feedback: rename, handle error --- react/features/invite/actions.js | 35 +++++++++++++++---- .../invite/components/DialInNumbersForm.js | 16 ++++----- react/features/invite/index.js | 1 + react/features/invite/middleware.js | 25 +++++++++++++ 4 files changed, 63 insertions(+), 14 deletions(-) create mode 100644 react/features/invite/middleware.js diff --git a/react/features/invite/actions.js b/react/features/invite/actions.js index 6e892b6e7..0c2a38063 100644 --- a/react/features/invite/actions.js +++ b/react/features/invite/actions.js @@ -10,9 +10,27 @@ declare var $: Function; declare var APP: Object; declare var config: Object; -const CONFERENCE_ID_ENDPOINT = config.conferenceMapperUrl; -const DIAL_IN_NUMBERS_ENDPOINT = config.dialInNumbersUrl; -const MUC_URL = config && config.hosts && config.hosts.muc; +/** + * The url for the api that matches a conference name and muc to an id. + * + * @type {string} + */ +const DIAL_IN_CONF_CODE_URL = config.dialInConfCodeUrl; + +/** + * The url for the api that returns phone numbers to dial in to the conference + * and join using the conference id. + * + * @type {string} + */ +const DIAL_IN_NUMBERS_URLS = config.dialInNumbersUrl; + +/** + * The url for the MUC component joined for the conference. + * + * @type {string} + */ +const MUC_URL = config.hosts && config.hosts.muc; /** * Opens the Invite Dialog. @@ -33,16 +51,21 @@ export function openInviteDialog() { export function updateDialInNumbers() { return (dispatch, getState) => { - if (!CONFERENCE_ID_ENDPOINT || !DIAL_IN_NUMBERS_ENDPOINT || !MUC_URL) { + if (!DIAL_IN_CONF_CODE_URL || !DIAL_IN_NUMBERS_URLS || !MUC_URL) { + dispatch({ + type: UPDATE_DIAL_IN_NUMBERS_FAILED, + error: 'URLs for fetching dial in numbers not properly defined' + }); + return; } const { room } = getState()['features/base/conference']; const conferenceIdUrl - = `${CONFERENCE_ID_ENDPOINT}?conference=${room}@${MUC_URL}`; + = `${DIAL_IN_CONF_CODE_URL}?conference=${room}@${MUC_URL}`; Promise.all([ - $.getJSON(DIAL_IN_NUMBERS_ENDPOINT), + $.getJSON(DIAL_IN_NUMBERS_URLS), $.getJSON(conferenceIdUrl) ]).then(([ numbersResponse, idResponse ]) => { if (!idResponse.conference || !idResponse.id) { diff --git a/react/features/invite/components/DialInNumbersForm.js b/react/features/invite/components/DialInNumbersForm.js index 47e8503c6..ab9001b74 100644 --- a/react/features/invite/components/DialInNumbersForm.js +++ b/react/features/invite/components/DialInNumbersForm.js @@ -26,16 +26,16 @@ class DialInNumbersForm extends Component { * @static */ static propTypes = { - /** - * The name of the current user. - */ - _currentUserName: React.PropTypes.string, - /** * The redux state representing the dial-in numbers feature. */ _dialIn: React.PropTypes.object, + /** + * The display name of the local user. + */ + _localUserDisplayName: React.PropTypes.string, + /** * The url for the JitsiConference. */ @@ -292,7 +292,7 @@ class DialInNumbersForm extends Component { _generateCopyText() { const welcome = this.props.t('invite.invitedYouTo', { meetingUrl: this.props.conferenceUrl, - userName: this.props._currentUserName + userName: this.props._localUserDisplayName }); const callNumber = this.props.t('invite.callNumber', @@ -390,7 +390,7 @@ class DialInNumbersForm extends Component { * @param {Object} state - The Redux state. * @private * @returns {{ - * _currentUserName: React.PropTypes.string, + * _localUserDisplayName: React.PropTypes.string, * _dialIn: React.PropTypes.object * }} */ @@ -399,7 +399,7 @@ function _mapStateToProps(state) { = getLocalParticipant(state['features/base/participants']); return { - _currentUserName: name, + _localUserDisplayName: name, _dialIn: state['features/invite/dial-in'] }; } diff --git a/react/features/invite/index.js b/react/features/invite/index.js index 582e1f9dd..085a8cab2 100644 --- a/react/features/invite/index.js +++ b/react/features/invite/index.js @@ -2,3 +2,4 @@ export * from './actions'; export * from './components'; import './reducer'; +import './middleware'; diff --git a/react/features/invite/middleware.js b/react/features/invite/middleware.js new file mode 100644 index 000000000..531f61efc --- /dev/null +++ b/react/features/invite/middleware.js @@ -0,0 +1,25 @@ +import { MiddlewareRegistry } from '../base/redux'; + +import { UPDATE_DIAL_IN_NUMBERS_FAILED } from './actionTypes'; + +const logger = require('jitsi-meet-logger').getLogger(__filename); + +/** + * Middleware that catches actions fetching dial-in numbers. + * + * @param {Store} store - Redux store. + * @returns {Function} + */ +// eslint-disable-next-line no-unused-vars +MiddlewareRegistry.register(store => next => action => { + const result = next(action); + + switch (action.type) { + case UPDATE_DIAL_IN_NUMBERS_FAILED: + logger.error('Error encountered while fetching dial-in numbers:', + action.error); + break; + } + + return result; +});