瀏覽代碼

ref(external API): emit CONFERENCE_WILL_JOIN on SET_ROOM

Make the external API emit CONFERENCE_WILL_JOIN early on SET_ROOM action
which occurs before the XMPP connection is created. At this point we
know that config has loaded and if there's a valid conference room to
be joined. We were thinking of doing that even on CONFIG_WILL_LOAD,
but that seemed to be to risky at this point.
master
paweldomas 7 年之前
父節點
當前提交
91a65735f9
共有 1 個檔案被更改,包括 38 行新增1 行删除
  1. 38
    1
      react/features/mobile/external-api/middleware.js

+ 38
- 1
react/features/mobile/external-api/middleware.js 查看文件

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
+    JITSI_CONFERENCE_URL_KEY,
12
+    SET_ROOM,
13
+    isRoomValid
12
 } from '../../base/conference';
14
 } from '../../base/conference';
13
 import { LOAD_CONFIG_ERROR } from '../../base/config';
15
 import { LOAD_CONFIG_ERROR } from '../../base/config';
14
 import { MiddlewareRegistry } from '../../base/redux';
16
 import { MiddlewareRegistry } from '../../base/redux';
67
         });
69
         });
68
         break;
70
         break;
69
     }
71
     }
72
+
73
+    case SET_ROOM:
74
+        _maybeTriggerEarlyConferenceWillJoin(store, action);
75
+        break;
70
     }
76
     }
71
 
77
 
72
     return result;
78
     return result;
115
     return description;
121
     return description;
116
 }
122
 }
117
 
123
 
124
+/**
125
+ * If {@link SET_ROOM} action happens for a valid conference room this method
126
+ * will emit an early {@link CONFERENCE_WILL_JOIN} event to let the external API
127
+ * know that a conference is being joined. Before that happens a connection must
128
+ * be created and only then base/conference feature would emit
129
+ * {@link CONFERENCE_WILL_JOIN}. That is fine for the Jitsi Meet app, because
130
+ * that's the a conference instance gets created, but it's too late for
131
+ * the external API to learn that. The latter {@link CONFERENCE_WILL_JOIN} is
132
+ * swallowed in {@link _swallowEvent}.
133
+ *
134
+ * @param {Store} store - The redux store.
135
+ * @param {Action} action - The redux action.
136
+ * @returns {void}
137
+ */
138
+function _maybeTriggerEarlyConferenceWillJoin(store, action) {
139
+    const { locationURL } = store.getState()['features/base/connection'];
140
+    const { room } = action;
141
+
142
+    isRoomValid(room) && locationURL && _sendEvent(
143
+        store,
144
+        _getSymbolDescription(CONFERENCE_WILL_JOIN),
145
+        /* data */ {
146
+            url: toURLString(locationURL)
147
+        });
148
+}
149
+
118
 /**
150
 /**
119
  * Sends an event to the native counterpart of the External API for a specific
151
  * Sends an event to the native counterpart of the External API for a specific
120
  * conference-related redux action.
152
  * conference-related redux action.
232
     switch (action.type) {
264
     switch (action.type) {
233
     case CONFERENCE_LEFT:
265
     case CONFERENCE_LEFT:
234
         return _swallowConferenceLeft(store, action, data);
266
         return _swallowConferenceLeft(store, action, data);
267
+    case CONFERENCE_WILL_JOIN:
268
+        // CONFERENCE_WILL_JOIN is dispatched to the external API on SET_ROOM,
269
+        // before the connection is created, so we need to swallow the original
270
+        // one emitted by base/conference.
271
+        return true;
235
 
272
 
236
     default:
273
     default:
237
         return false;
274
         return false;

Loading…
取消
儲存