SQUASH: changes based on feedback: rename, handle error

This commit is contained in:
Leonard Kim 2017-05-19 15:35:10 -07:00
parent 47c07c2e76
commit a14886031f
4 changed files with 63 additions and 14 deletions

View File

@ -10,9 +10,27 @@ declare var $: Function;
declare var APP: Object; declare var APP: Object;
declare var config: Object; declare var config: Object;
const CONFERENCE_ID_ENDPOINT = config.conferenceMapperUrl; /**
const DIAL_IN_NUMBERS_ENDPOINT = config.dialInNumbersUrl; * The url for the api that matches a conference name and muc to an id.
const MUC_URL = config && config.hosts && config.hosts.muc; *
* @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. * Opens the Invite Dialog.
@ -33,16 +51,21 @@ export function openInviteDialog() {
export function updateDialInNumbers() { export function updateDialInNumbers() {
return (dispatch, getState) => { 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; return;
} }
const { room } = getState()['features/base/conference']; const { room } = getState()['features/base/conference'];
const conferenceIdUrl const conferenceIdUrl
= `${CONFERENCE_ID_ENDPOINT}?conference=${room}@${MUC_URL}`; = `${DIAL_IN_CONF_CODE_URL}?conference=${room}@${MUC_URL}`;
Promise.all([ Promise.all([
$.getJSON(DIAL_IN_NUMBERS_ENDPOINT), $.getJSON(DIAL_IN_NUMBERS_URLS),
$.getJSON(conferenceIdUrl) $.getJSON(conferenceIdUrl)
]).then(([ numbersResponse, idResponse ]) => { ]).then(([ numbersResponse, idResponse ]) => {
if (!idResponse.conference || !idResponse.id) { if (!idResponse.conference || !idResponse.id) {

View File

@ -26,16 +26,16 @@ class DialInNumbersForm extends Component {
* @static * @static
*/ */
static propTypes = { static propTypes = {
/**
* The name of the current user.
*/
_currentUserName: React.PropTypes.string,
/** /**
* The redux state representing the dial-in numbers feature. * The redux state representing the dial-in numbers feature.
*/ */
_dialIn: React.PropTypes.object, _dialIn: React.PropTypes.object,
/**
* The display name of the local user.
*/
_localUserDisplayName: React.PropTypes.string,
/** /**
* The url for the JitsiConference. * The url for the JitsiConference.
*/ */
@ -292,7 +292,7 @@ class DialInNumbersForm extends Component {
_generateCopyText() { _generateCopyText() {
const welcome = this.props.t('invite.invitedYouTo', { const welcome = this.props.t('invite.invitedYouTo', {
meetingUrl: this.props.conferenceUrl, meetingUrl: this.props.conferenceUrl,
userName: this.props._currentUserName userName: this.props._localUserDisplayName
}); });
const callNumber = this.props.t('invite.callNumber', const callNumber = this.props.t('invite.callNumber',
@ -390,7 +390,7 @@ class DialInNumbersForm extends Component {
* @param {Object} state - The Redux state. * @param {Object} state - The Redux state.
* @private * @private
* @returns {{ * @returns {{
* _currentUserName: React.PropTypes.string, * _localUserDisplayName: React.PropTypes.string,
* _dialIn: React.PropTypes.object * _dialIn: React.PropTypes.object
* }} * }}
*/ */
@ -399,7 +399,7 @@ function _mapStateToProps(state) {
= getLocalParticipant(state['features/base/participants']); = getLocalParticipant(state['features/base/participants']);
return { return {
_currentUserName: name, _localUserDisplayName: name,
_dialIn: state['features/invite/dial-in'] _dialIn: state['features/invite/dial-in']
}; };
} }

View File

@ -2,3 +2,4 @@ export * from './actions';
export * from './components'; export * from './components';
import './reducer'; import './reducer';
import './middleware';

View File

@ -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;
});