[RN] Fix the conference URL delivered to JitsiMeetView's listeners

This commit is contained in:
Lyubo Marinov 2017-07-31 19:40:55 -05:00
parent 737419dbe8
commit 377be4272a
4 changed files with 31 additions and 25 deletions

View File

@ -29,7 +29,8 @@ import {
import {
AVATAR_ID_COMMAND,
AVATAR_URL_COMMAND,
EMAIL_COMMAND
EMAIL_COMMAND,
JITSI_CONFERENCE_URL_KEY
} from './constants';
import { _addLocalTracksToConference } from './functions';
@ -239,7 +240,7 @@ export function conferenceWillLeave(conference) {
export function createConference() {
return (dispatch, getState) => {
const state = getState();
const connection = state['features/base/connection'].connection;
const { connection, locationURL } = state['features/base/connection'];
if (!connection) {
throw new Error('Cannot create a conference without a connection!');
@ -258,6 +259,7 @@ export function createConference() {
room.toLowerCase(),
state['features/base/config']);
conference[JITSI_CONFERENCE_URL_KEY] = locationURL;
dispatch(_conferenceWillJoin(conference));
_addConferenceListeners(conference, dispatch);

View File

@ -18,3 +18,19 @@ export const AVATAR_URL_COMMAND = 'avatar-url';
* @type {string}
*/
export const EMAIL_COMMAND = 'email';
/**
* The name of the {@code JitsiConference} property which identifies the URL of
* the conference represented by the {@code JitsiConference} instance.
*
* TODO It was introduced in a moment of desperation. Jitsi Meet SDK for Android
* and iOS needs to deliver events from the JavaScript side where they originate
* to the Java and Objective-C sides, respectively, where they are to be
* handled. The URL of the {@code JitsiConference} was chosen as the identifier
* because the Java and Objective-C sides join by URL through their respective
* loadURL methods. But features/base/connection's {@code locationURL} is not
* guaranteed at the time of this writing to match the {@code JitsiConference}
* instance when the events are to be fired. Patching {@code JitsiConference}
* from the outside is not cool but it should suffice for now.
*/
export const JITSI_CONFERENCE_URL_KEY = Symbol('url');

View File

@ -13,7 +13,10 @@ export function getInviteURL(stateOrGetState: Function | Object): ?string {
= typeof stateOrGetState === 'function'
? stateOrGetState()
: stateOrGetState;
const { locationURL } = state['features/base/connection'];
const locationURL
= state instanceof URL
? state
: state['features/base/connection'].locationURL;
let inviteURL;
if (locationURL) {

View File

@ -7,9 +7,11 @@ import {
CONFERENCE_JOINED,
CONFERENCE_LEFT,
CONFERENCE_WILL_JOIN,
CONFERENCE_WILL_LEAVE
CONFERENCE_WILL_LEAVE,
JITSI_CONFERENCE_URL_KEY
} from '../../base/conference';
import { MiddlewareRegistry } from '../../base/redux';
import { toURLString } from '../../base/util';
/**
* Middleware that captures Redux actions and uses the ExternalAPI module to
@ -27,30 +29,13 @@ MiddlewareRegistry.register(store => next => action => {
case CONFERENCE_LEFT:
case CONFERENCE_WILL_JOIN:
case CONFERENCE_WILL_LEAVE: {
const { conference, room, type, ...data } = action;
const { conference, type, ...data } = action;
// For the above (redux) actions, conference and/or room identify a
// For the above (redux) actions, conference identifies a
// JitsiConference instance. The external API cannot transport such an
// object so we have to transport an "equivalent".
if (conference || room) {
// We have chosen to identify the object in question by the
// (supposedly) associated location URL. (FIXME Actually, the redux
// state locationURL is not really asssociated with the
// JitsiConference instance. The value of localtionURL is utilized
// in order to initialize the JitsiConference instance but the value
// of locationURL at the time of CONFERENCE_WILL_LEAVE and
// CONFERENCE_LEFT will not be the value with which the
// JitsiConference instance being left.)
const state = store.getState();
const { locationURL } = state['features/base/connection'];
if (!locationURL) {
// The (redux) action cannot be fully converted to an (external
// API) event.
break;
}
data.url = locationURL.href;
if (conference) {
data.url = toURLString(conference[JITSI_CONFERENCE_URL_KEY]);
}
// The (externa API) event's name is the string representation of the