diff --git a/lang/main.json b/lang/main.json index 75e67bcd9..0f1318286 100644 --- a/lang/main.json +++ b/lang/main.json @@ -435,11 +435,11 @@ "invite": { "addPassword": "Add password", "callNumber": "Call __number__", - "enterId": "Enter Meeting ID: __meetingId__ following by # to dial in from a phone", + "enterID": "Enter Meeting ID: __conferenceID__ following by # to dial in from a phone", "howToDialIn": "To dial in, use one of the following numbers and meeting ID", "hidePassword": "Hide password", "inviteTo": "Invite people to __conferenceName__", - "invitedYouTo": "__userName__ has invited you to the __meetingUrl__ conference", + "invitedYouTo": "__userName__ has invited you to the __inviteURL__ conference", "locked": "This call is locked. New callers must have the link and enter the password to join.", "showPassword": "Show password", "unlocked": "This call is unlocked. Any new caller with the link may join the call." diff --git a/modules/URL/ConferenceUrl.js b/modules/URL/ConferenceUrl.js index 78df779cf..45c4b947d 100644 --- a/modules/URL/ConferenceUrl.js +++ b/modules/URL/ConferenceUrl.js @@ -24,24 +24,9 @@ export default class ConferenceUrl { * from the sample URL. */ constructor(location) { - /** - * A simplified version of the conference URL stripped out of - * the parameters which should be used for sending invites. - * Example: - * https://example.com:8888/SomeConference1245 - * @type {string} - */ - this.inviteURL - = location.protocol + "//" + location.host + location.pathname; logger.info("Stored original conference URL: " + location.href); - logger.info("Conference URL for invites: " + this.inviteURL); - } - /** - * Obtains the conference invite URL. - * @return {string} the URL pointing o the conference which is mean to be - * used to invite new participants. - */ - getInviteUrl() { - return this.inviteURL; + logger.info( + "Conference URL for invites: " + location.protocol + "//" + + location.host + location.pathname); } } diff --git a/react/features/base/conference/actions.js b/react/features/base/conference/actions.js index 8040f309d..1e1c29fcb 100644 --- a/react/features/base/conference/actions.js +++ b/react/features/base/conference/actions.js @@ -121,12 +121,11 @@ function _addConferenceListeners(conference, dispatch) { * @returns {void} */ function _setLocalParticipantData(conference, state) { - const localParticipant - = getLocalParticipant(state['features/base/participants']); + const { avatarID } = getLocalParticipant(state); conference.removeCommand(AVATAR_ID_COMMAND); conference.sendCommand(AVATAR_ID_COMMAND, { - value: localParticipant.avatarID + value: avatarID }); } diff --git a/react/features/base/connection/functions.js b/react/features/base/connection/functions.js new file mode 100644 index 000000000..91667ee83 --- /dev/null +++ b/react/features/base/connection/functions.js @@ -0,0 +1,26 @@ +/* @flow */ + +/** + * Retrieves a simplified version of the conference/location URL stripped of URL + * params (i.e. query/search and hash) which should be used for sending invites. + * + * @param {Function|Object} stateOrGetState - The redux state or redux's + * {@code getState} function. + * @returns {string|undefined} + */ +export function getInviteURL(stateOrGetState: Function | Object): ?string { + const state + = typeof stateOrGetState === 'function' + ? stateOrGetState() + : stateOrGetState; + const { locationURL } = state['features/base/connection']; + let inviteURL; + + if (locationURL) { + const { host, pathname, protocol } = locationURL; + + inviteURL = `${protocol}//${host}${pathname}`; + } + + return inviteURL; +} diff --git a/react/features/base/connection/index.js b/react/features/base/connection/index.js index 81e1e72ee..03776f5f0 100644 --- a/react/features/base/connection/index.js +++ b/react/features/base/connection/index.js @@ -1,4 +1,5 @@ export * from './actions'; export * from './actionTypes'; +export * from './functions'; import './reducer'; diff --git a/react/features/base/participants/functions.js b/react/features/base/participants/functions.js index 75dadf59d..15d4495ea 100644 --- a/react/features/base/participants/functions.js +++ b/react/features/base/participants/functions.js @@ -69,13 +69,14 @@ export function getAvatarURL(participant) { /** * Returns local participant from Redux state. * - * @param {(Function|Participant[])} participantsOrGetState - Either the - * features/base/participants Redux state or Redux's getState function to be - * used to retrieve the features/base/participants state. + * @param {(Function|Object|Participant[])} stateOrGetState - The redux state + * features/base/participants, the (whole) redux state, or redux's + * {@code getState} function to be used to retrieve the + * features/base/participants state. * @returns {(Participant|undefined)} */ -export function getLocalParticipant(participantsOrGetState) { - const participants = _getParticipants(participantsOrGetState); +export function getLocalParticipant(stateOrGetState) { + const participants = _getParticipants(stateOrGetState); return participants.find(p => p.local); } @@ -83,15 +84,16 @@ export function getLocalParticipant(participantsOrGetState) { /** * Returns participant by ID from Redux state. * - * @param {(Function|Participant[])} participantsOrGetState - Either the - * features/base/participants Redux state or Redux's getState function to be - * used to retrieve the features/base/participants state. + * @param {(Function|Object|Participant[])} stateOrGetState - The redux state + * features/base/participants, the (whole) redux state, or redux's + * {@code getState} function to be used to retrieve the + * features/base/participants state. * @param {string} id - The ID of the participant to retrieve. * @private * @returns {(Participant|undefined)} */ -export function getParticipantById(participantsOrGetState, id) { - const participants = _getParticipants(participantsOrGetState); +export function getParticipantById(stateOrGetState, id) { + const participants = _getParticipants(stateOrGetState); return participants.find(p => p.id === id); } @@ -99,17 +101,22 @@ export function getParticipantById(participantsOrGetState, id) { /** * Returns array of participants from Redux state. * - * @param {(Function|Participant[])} participantsOrGetState - Either the - * features/base/participants Redux state or Redux's getState function to be - * used to retrieve the features/base/participants state. + * @param {(Function|Object|Participant[])} stateOrGetState - The redux state + * features/base/participants, the (whole) redux state, or redux's + * {@code getState} function to be used to retrieve the + * features/base/participants state. * @private * @returns {Participant[]} */ -function _getParticipants(participantsOrGetState) { - const participants - = typeof participantsOrGetState === 'function' - ? participantsOrGetState()['features/base/participants'] - : participantsOrGetState; +function _getParticipants(stateOrGetState) { + if (Array.isArray(stateOrGetState)) { + return stateOrGetState; + } - return participants || []; + const state + = typeof stateOrGetState === 'function' + ? stateOrGetState() + : stateOrGetState; + + return state['features/base/participants'] || []; } diff --git a/react/features/invite/actionTypes.js b/react/features/invite/actionTypes.js index 303745fad..c57de29bb 100644 --- a/react/features/invite/actionTypes.js +++ b/react/features/invite/actionTypes.js @@ -16,7 +16,8 @@ export const UPDATE_DIAL_IN_NUMBERS_FAILED * * { * type: UPDATE_DIAL_IN_NUMBERS_SUCCESS, - * response: Object + * conferenceID: Object, + * dialInNumbers: Object * } */ export const UPDATE_DIAL_IN_NUMBERS_SUCCESS diff --git a/react/features/invite/actions.js b/react/features/invite/actions.js index f9fb82f0b..65277de33 100644 --- a/react/features/invite/actions.js +++ b/react/features/invite/actions.js @@ -15,23 +15,22 @@ declare var APP: Object; * @returns {Function} */ export function openInviteDialog() { - return openDialog(InviteDialog, { - conferenceUrl: encodeURI(APP.ConferenceUrl.getInviteUrl()) - }); + return openDialog(InviteDialog); } /** - * Sends an ajax requests for dial-in numbers and conference id. + * Sends AJAX requests for dial-in numbers and conference ID. * * @returns {Function} */ export function updateDialInNumbers() { return (dispatch, getState) => { + const state = getState(); const { dialInConfCodeUrl, dialInNumbersUrl, hosts } - = getState()['features/base/config']; - const mucUrl = hosts && hosts.muc; + = state['features/base/config']; + const mucURL = hosts && hosts.muc; - if (!dialInConfCodeUrl || !dialInNumbersUrl || !mucUrl) { + if (!dialInConfCodeUrl || !dialInNumbersUrl || !mucURL) { dispatch({ type: UPDATE_DIAL_IN_NUMBERS_FAILED, error: 'URLs for fetching dial in numbers not properly defined' @@ -40,30 +39,30 @@ export function updateDialInNumbers() { return; } - const { room } = getState()['features/base/conference']; - const conferenceIdUrl - = `${dialInConfCodeUrl}?conference=${room}@${mucUrl}`; + const { room } = state['features/base/conference']; + const conferenceIDURL + = `${dialInConfCodeUrl}?conference=${room}@${mucURL}`; Promise.all([ $.getJSON(dialInNumbersUrl), - $.getJSON(conferenceIdUrl) - ]).then(([ numbersResponse, idResponse ]) => { - if (!idResponse.conference || !idResponse.id) { - return Promise.reject(idResponse.message); - } + $.getJSON(conferenceIDURL) + ]) + .then(([ dialInNumbers, { conference, id, message } ]) => { + if (!conference || !id) { + return Promise.reject(message); + } - dispatch({ - type: UPDATE_DIAL_IN_NUMBERS_SUCCESS, - conferenceId: idResponse, - dialInNumbers: numbersResponse + dispatch({ + type: UPDATE_DIAL_IN_NUMBERS_SUCCESS, + conferenceID: id, + dialInNumbers + }); + }) + .catch(error => { + dispatch({ + type: UPDATE_DIAL_IN_NUMBERS_FAILED, + error + }); }); - }) - .catch(error => { - dispatch({ - type: UPDATE_DIAL_IN_NUMBERS_FAILED, - error - }); - }); - }; } diff --git a/react/features/invite/components/DialInNumbersForm.js b/react/features/invite/components/DialInNumbersForm.js index 986c307a4..258981bc6 100644 --- a/react/features/invite/components/DialInNumbersForm.js +++ b/react/features/invite/components/DialInNumbersForm.js @@ -34,16 +34,17 @@ class DialInNumbersForm extends Component { */ _localUserDisplayName: React.PropTypes.string, - /** - * The url for the JitsiConference. - */ - conferenceUrl: React.PropTypes.string, - /** * Invoked to send an ajax request for dial-in numbers. */ dispatch: React.PropTypes.func, + /** + * The URL of the conference into which this {@code DialInNumbersForm} + * is inviting the local participant. + */ + inviteURL: React.PropTypes.string, + /** * Invoked to obtain translated strings. */ @@ -134,21 +135,21 @@ class DialInNumbersForm extends Component { */ render() { const { _dialIn, t } = this.props; - const { conferenceId, numbers, numbersEnabled } = _dialIn; + const { conferenceID, numbers, numbersEnabled } = _dialIn; const { selectedNumber } = this.state; - if (!conferenceId || !numbers || !numbersEnabled || !selectedNumber) { + if (!conferenceID || !numbers || !numbersEnabled || !selectedNumber) { return null; } - const items = numbers ? this._formatNumbers(numbers) : []; + const items = this._formatNumbers(numbers); return (