[RN] locationURL instead of inviteURL

The value of inviteURL is derived from locationURL by removing the hash
and query/search params in order to make it fit for display and/or
public purposes. The Jitsi Meet SDK consumers do not fall into that
category and our intention is to provide them with the URL they used
with JitsiMeetView.openURL(URL) anyway.

Also rewrites to remove repetition. I'm not saying the new source code
is better really but at least I got to examine it and comment on some of
its weaknesses.
pull/1633/merge jitsi-meet_2146
Lyubo Marinov 8 years ago
parent 01b397faef
commit e5cc8cd32b
  1. 80
      react/features/mobile/external-api/middleware.js

@ -2,7 +2,6 @@
import { NativeModules } from 'react-native'; import { NativeModules } from 'react-native';
import { getInviteURL } from '../../base/connection';
import { import {
CONFERENCE_FAILED, CONFERENCE_FAILED,
CONFERENCE_JOINED, CONFERENCE_JOINED,
@ -12,7 +11,6 @@ import {
} from '../../base/conference'; } from '../../base/conference';
import { MiddlewareRegistry } from '../../base/redux'; import { MiddlewareRegistry } from '../../base/redux';
/** /**
* Middleware that captures Redux actions and uses the ExternalAPI module to * Middleware that captures Redux actions and uses the ExternalAPI module to
* turn them into native events so the application knows about them. * turn them into native events so the application knows about them.
@ -21,52 +19,66 @@ import { MiddlewareRegistry } from '../../base/redux';
* @returns {Function} * @returns {Function}
*/ */
MiddlewareRegistry.register(store => next => action => { MiddlewareRegistry.register(store => next => action => {
const eventData = {}; const result = next(action);
switch (action.type) { switch (action.type) {
case CONFERENCE_FAILED: { case CONFERENCE_FAILED:
eventData.error = action.error; case CONFERENCE_JOINED:
eventData.url = getInviteURL(store.getState()); case CONFERENCE_LEFT:
_sendEvent('CONFERENCE_FAILED', eventData); case CONFERENCE_WILL_JOIN:
break; case CONFERENCE_WILL_LEAVE: {
} const { conference, room, type, ...data } = action;
case CONFERENCE_JOINED: { // For the above (redux) actions, conference and/or room identify a
eventData.url = getInviteURL(store.getState()); // JitsiConference instance. The external API cannot transport such an
_sendEvent('CONFERENCE_JOINED', eventData); // object so we have to transport an "equivalent".
break; 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 { locationURL }
= store.getState()['features/base/connection'];
case CONFERENCE_LEFT: { if (!locationURL) {
eventData.url = getInviteURL(store.getState()); // The (redux) action cannot be fully converted to an (external
_sendEvent('CONFERENCE_LEFT', eventData); // API) event.
break; break;
} }
case CONFERENCE_WILL_JOIN: { data.url = locationURL.href;
eventData.url = getInviteURL(store.getState()); }
_sendEvent('CONFERENCE_WILL_JOIN', eventData);
break;
}
case CONFERENCE_WILL_LEAVE: { // The (externa API) event's name is the string representation of the
eventData.url = getInviteURL(store.getState()); // (redux) action's type.
_sendEvent('CONFERENCE_WILL_LEAVE', eventData); let name = type.toString();
// XXX We are using Symbol for (redux) action types at the time of this
// writing so the Symbol's description should be used.
if (name.startsWith('Symbol(') && name.endsWith(')')) {
name = name.slice(7, -1);
}
_sendEvent(name, data);
break; break;
} }
} }
return next(action); return result;
}); });
/** /**
* Sends the given event to the native side of the application. Applications can * Sends a specific event to the native counterpart of the External API. Native
* then listen to the events using the mechanisms provided by the Jitsi Meet * apps may listen to such events via the mechanisms provided by the (native)
* SDK. * mobile Jitsi Meet SDK.
* *
* @param {string} name - Event name. * @param {string} name - The name of the event to send.
* @param {Object} data - Ancillary data for the event. * @param {Object} data - The details/specifics of the event to send determined
* by/associated with the specified {@code name}.
* @private * @private
* @returns {void} * @returns {void}
*/ */

Loading…
Cancel
Save