Переглянути джерело

Add set room url action

master
Ilya Daynatovich 8 роки тому
джерело
коміт
4f72225372

+ 13
- 2
react/features/app/actions.js Переглянути файл

@@ -1,4 +1,4 @@
1
-import { setRoom } from '../base/conference';
1
+import { setRoom, setRoomUrl } from '../base/conference';
2 2
 import { setConfig } from '../base/config';
3 3
 import { getDomain, setDomain } from '../base/connection';
4 4
 import { loadConfig } from '../base/lib-jitsi-meet';
@@ -34,6 +34,8 @@ export function appNavigate(uri) {
34 34
     return (dispatch, getState) => {
35 35
         const state = getState();
36 36
         const oldDomain = getDomain(state);
37
+        const defaultURL = state['features/app'].app._getDefaultURL();
38
+        let urlObject;
37 39
 
38 40
         // eslint-disable-next-line prefer-const
39 41
         let { domain, room } = _parseURIString(uri);
@@ -42,10 +44,19 @@ export function appNavigate(uri) {
42 44
         // default.
43 45
         if (typeof domain === 'undefined') {
44 46
             domain
45
-                = _parseURIString(state['features/app'].app._getDefaultURL())
47
+                = _parseURIString(defaultURL)
46 48
                     .domain;
47 49
         }
48 50
 
51
+        if (room) {
52
+            const splitUrl = uri.split(domain);
53
+            const urlWithoutDomain = splitUrl[splitUrl.length - 1];
54
+
55
+            urlObject = new URL(urlWithoutDomain, `https://${domain}`);
56
+        }
57
+
58
+        dispatch(setRoomUrl(urlObject));
59
+
49 60
         // TODO Kostiantyn Tsaregradskyi: We should probably detect if user is
50 61
         // currently in a conference and ask her if she wants to close the
51 62
         // current conference and start a new one with the new room name or

+ 10
- 0
react/features/base/conference/actionTypes.js Переглянути файл

@@ -148,3 +148,13 @@ export const SET_PASSWORD_FAILED = Symbol('SET_PASSWORD_FAILED');
148 148
  * }
149 149
  */
150 150
 export const SET_ROOM = Symbol('SET_ROOM');
151
+
152
+/**
153
+ * The type of (Redux) action which sets the room URL.
154
+ *
155
+ * {
156
+ *     type: SET_ROOM_URL,
157
+ *     roomURL: URL
158
+ * }
159
+ */
160
+export const SET_ROOM_URL = Symbol('SET_ROOM_URL');

+ 27
- 10
react/features/base/conference/actions.js Переглянути файл

@@ -24,7 +24,8 @@ import {
24 24
     SET_LASTN,
25 25
     SET_PASSWORD,
26 26
     SET_PASSWORD_FAILED,
27
-    SET_ROOM
27
+    SET_ROOM,
28
+    SET_ROOM_URL
28 29
 } from './actionTypes';
29 30
 import {
30 31
     AVATAR_ID_COMMAND,
@@ -183,9 +184,9 @@ export function conferenceJoined(conference) {
183 184
  * @param {JitsiConference} conference - The JitsiConference instance which was
184 185
  * left by the local participant.
185 186
  * @returns {{
186
- *      type: CONFERENCE_LEFT,
187
- *      conference: JitsiConference
188
- *  }}
187
+ *     type: CONFERENCE_LEFT,
188
+ *     conference: JitsiConference
189
+ * }}
189 190
  */
190 191
 export function conferenceLeft(conference) {
191 192
     return {
@@ -202,9 +203,9 @@ export function conferenceLeft(conference) {
202 203
  * @param {string} room - The room (name) which identifies the conference the
203 204
  * local participant will (try to) join.
204 205
  * @returns {{
205
- *      type: CONFERENCE_WILL_JOIN,
206
- *      room: string
207
- *  }}
206
+ *     type: CONFERENCE_WILL_JOIN,
207
+ *     room: string
208
+ * }}
208 209
  */
209 210
 function _conferenceWillJoin(room) {
210 211
     return {
@@ -222,9 +223,9 @@ function _conferenceWillJoin(room) {
222 223
  * @param {JitsiConference} conference - The JitsiConference instance which will
223 224
  * be left by the local participant.
224 225
  * @returns {{
225
- *      type: CONFERENCE_LEFT,
226
- *      conference: JitsiConference
227
- *  }}
226
+ *     type: CONFERENCE_LEFT,
227
+ *     conference: JitsiConference
228
+ * }}
228 229
  */
229 230
 export function conferenceWillLeave(conference) {
230 231
     return {
@@ -490,6 +491,22 @@ export function setRoom(room) {
490 491
     };
491 492
 }
492 493
 
494
+/**
495
+ * Sets the room URL.
496
+ *
497
+ * @param {string} roomURL - Room url.
498
+ * @returns {{
499
+ *     type: SET_ROOM_URL,
500
+ *     roomURL: URL
501
+ * }}
502
+ */
503
+export function setRoomURL(roomURL) {
504
+    return {
505
+        type: SET_ROOM_URL,
506
+        roomURL
507
+    };
508
+}
509
+
493 510
 /**
494 511
  * Toggles the audio-only flag for the current JitsiConference.
495 512
  *

+ 25
- 1
react/features/base/conference/reducer.js Переглянути файл

@@ -13,7 +13,8 @@ import {
13 13
     _SET_AUDIO_ONLY_VIDEO_MUTED,
14 14
     SET_LARGE_VIDEO_HD_STATUS,
15 15
     SET_PASSWORD,
16
-    SET_ROOM
16
+    SET_ROOM,
17
+    SET_ROOM_URL
17 18
 } from './actionTypes';
18 19
 import { isRoomValid } from './functions';
19 20
 
@@ -52,6 +53,9 @@ ReducerRegistry.register('features/base/conference', (state = {}, action) => {
52 53
 
53 54
     case SET_ROOM:
54 55
         return _setRoom(state, action);
56
+
57
+    case SET_ROOM_URL:
58
+        return _setRoomURL(state, action);
55 59
     }
56 60
 
57 61
     return state;
@@ -344,3 +348,23 @@ function _setRoom(state, action) {
344 348
      */
345 349
     return set(state, 'room', room);
346 350
 }
351
+
352
+/**
353
+ * Reduces a specific Redux action SET_ROOM_URL of the feature base/conference.
354
+ *
355
+ * @param {Object} state - The Redux state of the feature base/conference.
356
+ * @param {Action} action - The Redux action SET_ROOM_URL to reduce.
357
+ * @private
358
+ * @returns {Object} The new state of the feature base/conference after the
359
+ * reduction of the specified action.
360
+ */
361
+function _setRoomURL(state, action) {
362
+    const { roomURL } = action;
363
+
364
+    /**
365
+     * Room URL of the conference (to be) joined.
366
+     *
367
+     * @type {string}
368
+     */
369
+    return set(state, 'roomURL', roomURL);
370
+}

Завантаження…
Відмінити
Зберегти