Browse Source

Add set room url action

master
Ilya Daynatovich 8 years ago
parent
commit
4f72225372

+ 13
- 2
react/features/app/actions.js View File

1
-import { setRoom } from '../base/conference';
1
+import { setRoom, setRoomUrl } from '../base/conference';
2
 import { setConfig } from '../base/config';
2
 import { setConfig } from '../base/config';
3
 import { getDomain, setDomain } from '../base/connection';
3
 import { getDomain, setDomain } from '../base/connection';
4
 import { loadConfig } from '../base/lib-jitsi-meet';
4
 import { loadConfig } from '../base/lib-jitsi-meet';
34
     return (dispatch, getState) => {
34
     return (dispatch, getState) => {
35
         const state = getState();
35
         const state = getState();
36
         const oldDomain = getDomain(state);
36
         const oldDomain = getDomain(state);
37
+        const defaultURL = state['features/app'].app._getDefaultURL();
38
+        let urlObject;
37
 
39
 
38
         // eslint-disable-next-line prefer-const
40
         // eslint-disable-next-line prefer-const
39
         let { domain, room } = _parseURIString(uri);
41
         let { domain, room } = _parseURIString(uri);
42
         // default.
44
         // default.
43
         if (typeof domain === 'undefined') {
45
         if (typeof domain === 'undefined') {
44
             domain
46
             domain
45
-                = _parseURIString(state['features/app'].app._getDefaultURL())
47
+                = _parseURIString(defaultURL)
46
                     .domain;
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
         // TODO Kostiantyn Tsaregradskyi: We should probably detect if user is
60
         // TODO Kostiantyn Tsaregradskyi: We should probably detect if user is
50
         // currently in a conference and ask her if she wants to close the
61
         // currently in a conference and ask her if she wants to close the
51
         // current conference and start a new one with the new room name or
62
         // current conference and start a new one with the new room name or

+ 10
- 0
react/features/base/conference/actionTypes.js View File

148
  * }
148
  * }
149
  */
149
  */
150
 export const SET_ROOM = Symbol('SET_ROOM');
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 View File

24
     SET_LASTN,
24
     SET_LASTN,
25
     SET_PASSWORD,
25
     SET_PASSWORD,
26
     SET_PASSWORD_FAILED,
26
     SET_PASSWORD_FAILED,
27
-    SET_ROOM
27
+    SET_ROOM,
28
+    SET_ROOM_URL
28
 } from './actionTypes';
29
 } from './actionTypes';
29
 import {
30
 import {
30
     AVATAR_ID_COMMAND,
31
     AVATAR_ID_COMMAND,
183
  * @param {JitsiConference} conference - The JitsiConference instance which was
184
  * @param {JitsiConference} conference - The JitsiConference instance which was
184
  * left by the local participant.
185
  * left by the local participant.
185
  * @returns {{
186
  * @returns {{
186
- *      type: CONFERENCE_LEFT,
187
- *      conference: JitsiConference
188
- *  }}
187
+ *     type: CONFERENCE_LEFT,
188
+ *     conference: JitsiConference
189
+ * }}
189
  */
190
  */
190
 export function conferenceLeft(conference) {
191
 export function conferenceLeft(conference) {
191
     return {
192
     return {
202
  * @param {string} room - The room (name) which identifies the conference the
203
  * @param {string} room - The room (name) which identifies the conference the
203
  * local participant will (try to) join.
204
  * local participant will (try to) join.
204
  * @returns {{
205
  * @returns {{
205
- *      type: CONFERENCE_WILL_JOIN,
206
- *      room: string
207
- *  }}
206
+ *     type: CONFERENCE_WILL_JOIN,
207
+ *     room: string
208
+ * }}
208
  */
209
  */
209
 function _conferenceWillJoin(room) {
210
 function _conferenceWillJoin(room) {
210
     return {
211
     return {
222
  * @param {JitsiConference} conference - The JitsiConference instance which will
223
  * @param {JitsiConference} conference - The JitsiConference instance which will
223
  * be left by the local participant.
224
  * be left by the local participant.
224
  * @returns {{
225
  * @returns {{
225
- *      type: CONFERENCE_LEFT,
226
- *      conference: JitsiConference
227
- *  }}
226
+ *     type: CONFERENCE_LEFT,
227
+ *     conference: JitsiConference
228
+ * }}
228
  */
229
  */
229
 export function conferenceWillLeave(conference) {
230
 export function conferenceWillLeave(conference) {
230
     return {
231
     return {
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
  * Toggles the audio-only flag for the current JitsiConference.
511
  * Toggles the audio-only flag for the current JitsiConference.
495
  *
512
  *

+ 25
- 1
react/features/base/conference/reducer.js View File

13
     _SET_AUDIO_ONLY_VIDEO_MUTED,
13
     _SET_AUDIO_ONLY_VIDEO_MUTED,
14
     SET_LARGE_VIDEO_HD_STATUS,
14
     SET_LARGE_VIDEO_HD_STATUS,
15
     SET_PASSWORD,
15
     SET_PASSWORD,
16
-    SET_ROOM
16
+    SET_ROOM,
17
+    SET_ROOM_URL
17
 } from './actionTypes';
18
 } from './actionTypes';
18
 import { isRoomValid } from './functions';
19
 import { isRoomValid } from './functions';
19
 
20
 
52
 
53
 
53
     case SET_ROOM:
54
     case SET_ROOM:
54
         return _setRoom(state, action);
55
         return _setRoom(state, action);
56
+
57
+    case SET_ROOM_URL:
58
+        return _setRoomURL(state, action);
55
     }
59
     }
56
 
60
 
57
     return state;
61
     return state;
344
      */
348
      */
345
     return set(state, 'room', room);
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
+}

Loading…
Cancel
Save