Add set room url action
This commit is contained in:
parent
3af0976a43
commit
4f72225372
|
@ -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
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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,
|
||||
|
@ -183,9 +184,9 @@ export function conferenceJoined(conference) {
|
|||
* @param {JitsiConference} conference - The JitsiConference instance which was
|
||||
* left by the local participant.
|
||||
* @returns {{
|
||||
* type: CONFERENCE_LEFT,
|
||||
* conference: JitsiConference
|
||||
* }}
|
||||
* type: CONFERENCE_LEFT,
|
||||
* conference: JitsiConference
|
||||
* }}
|
||||
*/
|
||||
export function conferenceLeft(conference) {
|
||||
return {
|
||||
|
@ -202,9 +203,9 @@ export function conferenceLeft(conference) {
|
|||
* @param {string} room - The room (name) which identifies the conference the
|
||||
* local participant will (try to) join.
|
||||
* @returns {{
|
||||
* type: CONFERENCE_WILL_JOIN,
|
||||
* room: string
|
||||
* }}
|
||||
* type: CONFERENCE_WILL_JOIN,
|
||||
* room: string
|
||||
* }}
|
||||
*/
|
||||
function _conferenceWillJoin(room) {
|
||||
return {
|
||||
|
@ -222,9 +223,9 @@ function _conferenceWillJoin(room) {
|
|||
* @param {JitsiConference} conference - The JitsiConference instance which will
|
||||
* be left by the local participant.
|
||||
* @returns {{
|
||||
* type: CONFERENCE_LEFT,
|
||||
* conference: JitsiConference
|
||||
* }}
|
||||
* type: CONFERENCE_LEFT,
|
||||
* conference: JitsiConference
|
||||
* }}
|
||||
*/
|
||||
export function conferenceWillLeave(conference) {
|
||||
return {
|
||||
|
@ -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.
|
||||
*
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue