Add set room url action

This commit is contained in:
Ilya Daynatovich 2017-04-19 17:52:27 +03:00 committed by Lyubo Marinov
parent 3af0976a43
commit 4f72225372
4 changed files with 75 additions and 13 deletions

View File

@ -1,4 +1,4 @@
import { setRoom } from '../base/conference';
import { setRoom, setRoomUrl } from '../base/conference';
import { setConfig } from '../base/config';
import { getDomain, setDomain } from '../base/connection';
import { loadConfig } from '../base/lib-jitsi-meet';
@ -34,6 +34,8 @@ export function appNavigate(uri) {
return (dispatch, getState) => {
const state = getState();
const oldDomain = getDomain(state);
const defaultURL = state['features/app'].app._getDefaultURL();
let urlObject;
// eslint-disable-next-line prefer-const
let { domain, room } = _parseURIString(uri);
@ -42,10 +44,19 @@ export function appNavigate(uri) {
// default.
if (typeof domain === 'undefined') {
domain
= _parseURIString(state['features/app'].app._getDefaultURL())
= _parseURIString(defaultURL)
.domain;
}
if (room) {
const splitUrl = uri.split(domain);
const urlWithoutDomain = splitUrl[splitUrl.length - 1];
urlObject = new URL(urlWithoutDomain, `https://${domain}`);
}
dispatch(setRoomUrl(urlObject));
// TODO Kostiantyn Tsaregradskyi: We should probably detect if user is
// currently in a conference and ask her if she wants to close the
// current conference and start a new one with the new room name or

View File

@ -148,3 +148,13 @@ export const SET_PASSWORD_FAILED = Symbol('SET_PASSWORD_FAILED');
* }
*/
export const SET_ROOM = Symbol('SET_ROOM');
/**
* The type of (Redux) action which sets the room URL.
*
* {
* type: SET_ROOM_URL,
* roomURL: URL
* }
*/
export const SET_ROOM_URL = Symbol('SET_ROOM_URL');

View File

@ -24,7 +24,8 @@ import {
SET_LASTN,
SET_PASSWORD,
SET_PASSWORD_FAILED,
SET_ROOM
SET_ROOM,
SET_ROOM_URL
} from './actionTypes';
import {
AVATAR_ID_COMMAND,
@ -490,6 +491,22 @@ export function setRoom(room) {
};
}
/**
* Sets the room URL.
*
* @param {string} roomURL - Room url.
* @returns {{
* type: SET_ROOM_URL,
* roomURL: URL
* }}
*/
export function setRoomURL(roomURL) {
return {
type: SET_ROOM_URL,
roomURL
};
}
/**
* Toggles the audio-only flag for the current JitsiConference.
*

View File

@ -13,7 +13,8 @@ import {
_SET_AUDIO_ONLY_VIDEO_MUTED,
SET_LARGE_VIDEO_HD_STATUS,
SET_PASSWORD,
SET_ROOM
SET_ROOM,
SET_ROOM_URL
} from './actionTypes';
import { isRoomValid } from './functions';
@ -52,6 +53,9 @@ ReducerRegistry.register('features/base/conference', (state = {}, action) => {
case SET_ROOM:
return _setRoom(state, action);
case SET_ROOM_URL:
return _setRoomURL(state, action);
}
return state;
@ -344,3 +348,23 @@ function _setRoom(state, action) {
*/
return set(state, 'room', room);
}
/**
* Reduces a specific Redux action SET_ROOM_URL of the feature base/conference.
*
* @param {Object} state - The Redux state of the feature base/conference.
* @param {Action} action - The Redux action SET_ROOM_URL to reduce.
* @private
* @returns {Object} The new state of the feature base/conference after the
* reduction of the specified action.
*/
function _setRoomURL(state, action) {
const { roomURL } = action;
/**
* Room URL of the conference (to be) joined.
*
* @type {string}
*/
return set(state, 'roomURL', roomURL);
}