Procházet zdrojové kódy

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

master
Lyubo Marinov před 7 roky
rodič
revize
377be4272a

+ 4
- 2
react/features/base/conference/actions.js Zobrazit soubor

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

+ 16
- 0
react/features/base/conference/constants.js Zobrazit soubor

@@ -18,3 +18,19 @@ export const AVATAR_URL_COMMAND = 'avatar-url';
18 18
  * @type {string}
19 19
  */
20 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 Zobrazit soubor

@@ -13,7 +13,10 @@ export function getInviteURL(stateOrGetState: Function | Object): ?string {
13 13
         = typeof stateOrGetState === 'function'
14 14
             ? stateOrGetState()
15 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 20
     let inviteURL;
18 21
 
19 22
     if (locationURL) {

+ 7
- 22
react/features/mobile/external-api/middleware.js Zobrazit soubor

@@ -7,9 +7,11 @@ import {
7 7
     CONFERENCE_JOINED,
8 8
     CONFERENCE_LEFT,
9 9
     CONFERENCE_WILL_JOIN,
10
-    CONFERENCE_WILL_LEAVE
10
+    CONFERENCE_WILL_LEAVE,
11
+    JITSI_CONFERENCE_URL_KEY
11 12
 } from '../../base/conference';
12 13
 import { MiddlewareRegistry } from '../../base/redux';
14
+import { toURLString } from '../../base/util';
13 15
 
14 16
 /**
15 17
  * Middleware that captures Redux actions and uses the ExternalAPI module to
@@ -27,30 +29,13 @@ MiddlewareRegistry.register(store => next => action => {
27 29
     case CONFERENCE_LEFT:
28 30
     case CONFERENCE_WILL_JOIN:
29 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 35
         // JitsiConference instance. The external API cannot transport such an
34 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 41
         // The (externa API) event's name is the string representation of the

Načítá se…
Zrušit
Uložit