Browse Source

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

master
Lyubo Marinov 7 years ago
parent
commit
377be4272a

+ 4
- 2
react/features/base/conference/actions.js View File

29
 import {
29
 import {
30
     AVATAR_ID_COMMAND,
30
     AVATAR_ID_COMMAND,
31
     AVATAR_URL_COMMAND,
31
     AVATAR_URL_COMMAND,
32
-    EMAIL_COMMAND
32
+    EMAIL_COMMAND,
33
+    JITSI_CONFERENCE_URL_KEY
33
 } from './constants';
34
 } from './constants';
34
 import { _addLocalTracksToConference } from './functions';
35
 import { _addLocalTracksToConference } from './functions';
35
 
36
 
239
 export function createConference() {
240
 export function createConference() {
240
     return (dispatch, getState) => {
241
     return (dispatch, getState) => {
241
         const state = getState();
242
         const state = getState();
242
-        const connection = state['features/base/connection'].connection;
243
+        const { connection, locationURL } = state['features/base/connection'];
243
 
244
 
244
         if (!connection) {
245
         if (!connection) {
245
             throw new Error('Cannot create a conference without a connection!');
246
             throw new Error('Cannot create a conference without a connection!');
258
                 room.toLowerCase(),
259
                 room.toLowerCase(),
259
                 state['features/base/config']);
260
                 state['features/base/config']);
260
 
261
 
262
+        conference[JITSI_CONFERENCE_URL_KEY] = locationURL;
261
         dispatch(_conferenceWillJoin(conference));
263
         dispatch(_conferenceWillJoin(conference));
262
 
264
 
263
         _addConferenceListeners(conference, dispatch);
265
         _addConferenceListeners(conference, dispatch);

+ 16
- 0
react/features/base/conference/constants.js View File

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

+ 4
- 1
react/features/base/connection/functions.js View File

13
         = typeof stateOrGetState === 'function'
13
         = typeof stateOrGetState === 'function'
14
             ? stateOrGetState()
14
             ? stateOrGetState()
15
             : stateOrGetState;
15
             : stateOrGetState;
16
-    const { locationURL } = state['features/base/connection'];
16
+    const locationURL
17
+        = state instanceof URL
18
+            ? state
19
+            : state['features/base/connection'].locationURL;
17
     let inviteURL;
20
     let inviteURL;
18
 
21
 
19
     if (locationURL) {
22
     if (locationURL) {

+ 7
- 22
react/features/mobile/external-api/middleware.js View File

7
     CONFERENCE_JOINED,
7
     CONFERENCE_JOINED,
8
     CONFERENCE_LEFT,
8
     CONFERENCE_LEFT,
9
     CONFERENCE_WILL_JOIN,
9
     CONFERENCE_WILL_JOIN,
10
-    CONFERENCE_WILL_LEAVE
10
+    CONFERENCE_WILL_LEAVE,
11
+    JITSI_CONFERENCE_URL_KEY
11
 } from '../../base/conference';
12
 } from '../../base/conference';
12
 import { MiddlewareRegistry } from '../../base/redux';
13
 import { MiddlewareRegistry } from '../../base/redux';
14
+import { toURLString } from '../../base/util';
13
 
15
 
14
 /**
16
 /**
15
  * Middleware that captures Redux actions and uses the ExternalAPI module to
17
  * Middleware that captures Redux actions and uses the ExternalAPI module to
27
     case CONFERENCE_LEFT:
29
     case CONFERENCE_LEFT:
28
     case CONFERENCE_WILL_JOIN:
30
     case CONFERENCE_WILL_JOIN:
29
     case CONFERENCE_WILL_LEAVE: {
31
     case CONFERENCE_WILL_LEAVE: {
30
-        const { conference, room, type, ...data } = action;
32
+        const { conference, type, ...data } = action;
31
 
33
 
32
-        // For the above (redux) actions, conference and/or room identify a
34
+        // For the above (redux) actions, conference identifies a
33
         // JitsiConference instance. The external API cannot transport such an
35
         // JitsiConference instance. The external API cannot transport such an
34
         // object so we have to transport an "equivalent".
36
         // object so we have to transport an "equivalent".
35
-        if (conference || room) {
36
-            // We have chosen to identify the object in question by the
37
-            // (supposedly) associated location URL. (FIXME Actually, the redux
38
-            // state locationURL is not really asssociated with the
39
-            // JitsiConference instance. The value of localtionURL is utilized
40
-            // in order to initialize the JitsiConference instance but the value
41
-            // of locationURL at the time of CONFERENCE_WILL_LEAVE and
42
-            // CONFERENCE_LEFT will not be the value with which the
43
-            // JitsiConference instance being left.)
44
-            const state = store.getState();
45
-            const { locationURL } = state['features/base/connection'];
46
-
47
-            if (!locationURL) {
48
-                // The (redux) action cannot be fully converted to an (external
49
-                // API) event.
50
-                break;
51
-            }
52
-
53
-            data.url = locationURL.href;
37
+        if (conference) {
38
+            data.url = toURLString(conference[JITSI_CONFERENCE_URL_KEY]);
54
         }
39
         }
55
 
40
 
56
         // The (externa API) event's name is the string representation of the
41
         // The (externa API) event's name is the string representation of the

Loading…
Cancel
Save