Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

feat: Drops connection on prejoin screen. (#13538)

Дамян Минковbc23f9cd332f
diff --git a/conference.js b/conference.js
index 950b3703ff..4c215ef996 100644
--- a/conference.js
+++ b/conference.js
@@ -4,12 +4,8 @@ import { jitsiLocalStorage } from '@jitsi/js-utils';
import Logger from '@jitsi/logger';
import EventEmitter from 'events';
-import { openConnection } from './connection';
import { ENDPOINT_TEXT_MESSAGE_NAME } from './modules/API/constants';
import { AUDIO_ONLY_SCREEN_SHARE_NO_TRACK } from './modules/UI/UIErrors';
-import AuthHandler from './modules/UI/authentication/AuthHandler';
-import UIUtil from './modules/UI/util/UIUtil';
-import VideoLayout from './modules/UI/videolayout/VideoLayout';
import mediaDeviceHelper from './modules/devices/mediaDeviceHelper';
import Recorder from './modules/recorder/Recorder';
import { createTaskQueue } from './modules/util/helpers';
@@ -37,7 +33,7 @@ import {
conferenceSubjectChanged,
conferenceTimestampChanged,
conferenceUniqueIdSet,
- conferenceWillJoin,
+ conferenceWillInit,
conferenceWillLeave,
dataChannelClosed,
dataChannelOpened,
@@ -57,12 +53,10 @@ import {
commonUserJoinedHandling,
commonUserLeftHandling,
getConferenceOptions,
- getVisitorOptions,
- restoreConferenceOptions,
sendLocalParticipant
} from './react/features/base/conference/functions';
-import { overwriteConfig } from './react/features/base/config/actions';
import { getReplaceParticipant } from './react/features/base/config/functions';
+import { connect } from './react/features/base/connection/actions.web';
import {
checkAndNotifyForNewDevice,
getAvailableDevices,
@@ -77,15 +71,12 @@ import {
import {
JitsiConferenceErrors,
JitsiConferenceEvents,
- JitsiConnectionErrors,
- JitsiConnectionEvents,
JitsiE2ePingEvents,
JitsiMediaDevicesEvents,
JitsiTrackErrors,
JitsiTrackEvents,
browser
} from './react/features/base/lib-jitsi-meet';
-import { isFatalJitsiConnectionError } from './react/features/base/lib-jitsi-meet/functions';
import {
gumPending,
setAudioAvailable,
@@ -145,7 +136,12 @@ import { maybeOpenFeedbackDialog, submitFeedback } from './react/features/feedba
import { initKeyboardShortcuts } from './react/features/keyboard-shortcuts/actions';
import { maybeSetLobbyChatMessageListener } from './react/features/lobby/actions.any';
import { setNoiseSuppressionEnabled } from './react/features/noise-suppression/actions';
-import { hideNotification, showNotification, showWarningNotification } from './react/features/notifications/actions';
+import {
+ hideNotification,
+ showErrorNotification,
+ showNotification,
+ showWarningNotification
+} from './react/features/notifications/actions';
import {
DATA_CHANNEL_CLOSED_NOTIFICATION_ID,
NOTIFICATION_TIMEOUT_TYPE
@@ -153,7 +149,7 @@ import {
import { isModerationNotificationDisplayed } from './react/features/notifications/functions';
import { mediaPermissionPromptVisibilityChanged } from './react/features/overlay/actions';
import { suspendDetected } from './react/features/power-monitor/actions';
-import { initPrejoin, makePrecallTest, setJoiningInProgress } from './react/features/prejoin/actions';
+import { initPrejoin, makePrecallTest } from './react/features/prejoin/actions';
import { isPrejoinPageVisible } from './react/features/prejoin/functions';
import { disableReceiver, stopReceiver } from './react/features/remote-control/actions';
import { setScreenAudioShareState } from './react/features/screen-share/actions.web';
@@ -164,7 +160,6 @@ import { createRnnoiseProcessor } from './react/features/stream-effects/rnnoise'
import { endpointMessageReceived } from './react/features/subtitles/actions.any';
import { handleToggleVideoMuted } from './react/features/toolbox/actions.any';
import { muteLocal } from './react/features/video-menu/actions.any';
-import { setIAmVisitor } from './react/features/visitors/actions';
import { iAmVisitor } from './react/features/visitors/functions';
import UIEvents from './service/UI/UIEvents';
@@ -173,25 +168,6 @@ const logger = Logger.getLogger(__filename);
const eventEmitter = new EventEmitter();
let room;
-let connection;
-
-/**
- * The promise is used when the prejoin screen is shown.
- * While the user configures the devices the connection can be made.
- *
- * @type {Promise<Object>}
- * @private
- */
-let _connectionPromise;
-
-/**
- * We are storing the resolve function of a Promise that waits for the _connectionPromise to be created. This is needed
- * when the prejoin button was pressed before the conference object was initialized and the _connectionPromise has not
- * been initialized when we tried to execute prejoinStart. In this case in prejoinStart we create a new Promise, assign
- * the resolve function to this variable and wait for the promise to resolve before we continue. The
- * _onConnectionPromiseCreated will be called once the _connectionPromise is created.
- */
-let _onConnectionPromiseCreated;
/*
* Logic to open a desktop picker put on the window global for
@@ -213,26 +189,6 @@ const commands = {
ETHERPAD: 'etherpad'
};
-/**
- * Open Connection. When authentication failed it shows auth dialog.
- * @param roomName the room name to use
- * @returns Promise<JitsiConnection>
- */
-function connect(roomName) {
- return openConnection({
- retry: true,
- roomName
- })
- .catch(err => {
- if (err === JitsiConnectionErrors.PASSWORD_REQUIRED) {
- APP.UI.notifyTokenAuthFailed();
- } else {
- APP.UI.notifyConnectionFailed(err);
- }
- throw err;
- });
-}
-
/**
* Share data to other users.
* @param command the command
@@ -326,63 +282,25 @@ class ConferenceConnector {
break;
}
- // not enough rights to create conference
- case JitsiConferenceErrors.AUTHENTICATION_REQUIRED: {
-
- const replaceParticipant = getReplaceParticipant(APP.store.getState());
-
- // Schedule reconnect to check if someone else created the room.
- this.reconnectTimeout = setTimeout(() => {
- APP.store.dispatch(conferenceWillJoin(room));
- room.join(null, replaceParticipant);
- }, 5000);
-
- const { password }
- = APP.store.getState()['features/base/conference'];
-
- AuthHandler.requireAuth(room, password);
-
- break;
- }
-
case JitsiConferenceErrors.RESERVATION_ERROR: {
const [ code, msg ] = params;
- APP.UI.notifyReservationError(code, msg);
- break;
- }
-
- case JitsiConferenceErrors.REDIRECTED: {
- const newConfig = getVisitorOptions(APP.store.getState(), params);
-
- if (!newConfig) {
- logger.warn('Not redirected missing params');
- break;
- }
-
- const [ vnode ] = params;
-
- APP.store.dispatch(overwriteConfig(newConfig))
- .then(() => this._conference.leaveRoom())
- .then(() => APP.store.dispatch(setIAmVisitor(Boolean(vnode))))
-
- // we do not clear local tracks on error, so we need to manually clear them
- .then(() => APP.store.dispatch(destroyLocalTracks()))
- .then(() => {
- // Reset VideoLayout. It's destroyed in features/video-layout/middleware.web.js so re-initialize it.
- VideoLayout.initLargeVideo();
- VideoLayout.resizeVideoArea();
-
- connect(this._conference.roomName).then(con => {
- this._conference.startConference(con, []);
- });
- });
-
+ APP.store.dispatch(showErrorNotification({
+ descriptionArguments: {
+ code,
+ msg
+ },
+ descriptionKey: 'dialog.reservationErrorMsg',
+ titleKey: 'dialog.reservationError'
+ }, NOTIFICATION_TIMEOUT_TYPE.LONG));
break;
}
case JitsiConferenceErrors.GRACEFUL_SHUTDOWN:
- APP.UI.notifyGracefulShutdown();
+ APP.store.dispatch(showErrorNotification({
+ descriptionKey: 'dialog.gracefulShutdown',
+ titleKey: 'dialog.serviceUnavailable'
+ }, NOTIFICATION_TIMEOUT_TYPE.LONG));
break;
// FIXME FOCUS_DISCONNECTED is a confusing event name.
@@ -408,31 +326,9 @@ class ConferenceConnector {
// FIXME the conference should be stopped by the library and not by
// the app. Both the errors above are unrecoverable from the library
// perspective.
- room.leave(CONFERENCE_LEAVE_REASONS.UNRECOVERABLE_ERROR).then(() => connection.disconnect());
+ room.leave(CONFERENCE_LEAVE_REASONS.UNRECOVERABLE_ERROR).then(() => APP.connection.disconnect());
break;
- case JitsiConferenceErrors.CONFERENCE_MAX_USERS: {
- APP.UI.notifyMaxUsersLimitReached();
-
- // in case of max users(it can be from a visitor node), let's restore
- // oldConfig if any as we will be back to the main prosody
- const newConfig = restoreConferenceOptions(APP.store.getState());
-
- if (newConfig) {
- APP.store.dispatch(overwriteConfig(newConfig))
- .then(() => this._conference.leaveRoom())
- .then(() => {
- _connectionPromise = connect(this._conference.roomName);
-
- return _connectionPromise;
- })
- .then(con => {
- APP.connection = connection = con;
- });
- }
-
- break;
- }
case JitsiConferenceErrors.INCOMPATIBLE_SERVER_VERSIONS:
APP.store.dispatch(reloadWithStoredParams());
break;
@@ -488,11 +384,11 @@ function disconnect() {
return Promise.resolve();
};
- if (!connection) {
+ if (!APP.connection) {
return onDisconnected();
}
- return connection.disconnect().then(onDisconnected, onDisconnected);
+ return APP.connection.disconnect().then(onDisconnected, onDisconnected);
}
/**
@@ -510,25 +406,6 @@ function setGUMPendingStateOnFailedTracks(tracks) {
APP.store.dispatch(gumPending(nonPendingTracks, IGUMPendingState.NONE));
}
-/**
- * Handles CONNECTION_FAILED events from lib-jitsi-meet.
- *
- * @param {JitsiConnectionError} error - The reported error.
- * @returns {void}
- * @private
- */
-function _connectionFailedHandler(error) {
- if (isFatalJitsiConnectionError(error)) {
- APP.connection.removeEventListener(
- JitsiConnectionEvents.CONNECTION_FAILED,
- _connectionFailedHandler);
- if (room) {
- APP.store.dispatch(conferenceWillLeave(room));
- room.leave(CONFERENCE_LEAVE_REASONS.UNRECOVERABLE_ERROR);
- }
- }
-}
-
export default {
/**
* Flag used to delay modification of the muted status of local media tracks
@@ -547,7 +424,16 @@ export default {
/**
* Returns an object containing a promise which resolves with the created tracks &
* the errors resulting from that process.
- *
+ * @param {object} options
+ * @param {boolean} options.startAudioOnly=false - if <tt>true</tt> then
+ * only audio track will be created and the audio only mode will be turned
+ * on.
+ * @param {boolean} options.startScreenSharing=false - if <tt>true</tt>
+ * should start with screensharing instead of camera video.
+ * @param {boolean} options.startWithAudioMuted - will start the conference
+ * without any audio tracks.
+ * @param {boolean} options.startWithVideoMuted - will start the conference
+ * without any video tracks.
* @returns {Promise<JitsiLocalTrack[]>, Object}
*/
createInitialLocalTracks(options = {}) {
@@ -725,37 +611,7 @@ export default {
}
},
- /**
- * Creates local media tracks and connects to a room. Will show error
- * dialogs in case accessing the local microphone and/or camera failed. Will
- * show guidance overlay for users on how to give access to camera and/or
- * microphone.
- * @param {string} roomName
- * @param {object} options
- * @param {boolean} options.startAudioOnly=false - if <tt>true</tt> then
- * only audio track will be created and the audio only mode will be turned
- * on.
- * @param {boolean} options.startScreenSharing=false - if <tt>true</tt>
- * should start with screensharing instead of camera video.
- * @param {boolean} options.startWithAudioMuted - will start the conference
- * without any audio tracks.
- * @param {boolean} options.startWithVideoMuted - will start the conference
- * without any video tracks.
- * @returns {Promise.<JitsiLocalTrack[], JitsiConnection>}
- */
- createInitialLocalTracksAndConnect(roomName, options = {}) {
- const { tryCreateLocalTracks, errors } = this.createInitialLocalTracks(options);
-
- return Promise.all([ tryCreateLocalTracks, connect(roomName) ])
- .then(([ tracks, con ]) => {
-
- this._displayErrorsForCreateInitialLocalTracks(errors);
-
- return [ tracks, con ];
- });
- },
-
- startConference(con, tracks) {
+ startConference(tracks) {
tracks.forEach(track => {
if ((track.isAudioTrack() && this.isLocalAudioMuted())
|| (track.isVideoTrack() && this.isLocalVideoMuted())) {
@@ -768,9 +624,6 @@ export default {
}
});
- con.addEventListener(JitsiConnectionEvents.CONNECTION_FAILED, _connectionFailedHandler);
- APP.connection = connection = con;
-
this._createRoom(tracks);
// if user didn't give access to mic or camera or doesn't have
@@ -860,17 +713,6 @@ export default {
};
if (isPrejoinPageVisible(state)) {
- _connectionPromise = connect(roomName).then(c => {
- // We want to initialize it early, in case of errors to be able to gather logs.
- APP.connection = c;
-
- return c;
- });
-
- if (_onConnectionPromiseCreated) {
- _onConnectionPromiseCreated();
- }
-
APP.store.dispatch(makePrecallTest(this._getConferenceOptions()));
const { tryCreateLocalTracks, errors } = this.createInitialLocalTracks(initialOptions);
@@ -897,41 +739,26 @@ export default {
return this._setLocalAudioVideoStreams(tracks);
}
- const [ tracks, con ] = await this.createInitialLocalTracksAndConnect(roomName, initialOptions);
+ const { tryCreateLocalTracks, errors } = this.createInitialLocalTracks(initialOptions);
- this._initDeviceList(true);
+ return Promise.all([
+ tryCreateLocalTracks.then(tr => {
+ this._displayErrorsForCreateInitialLocalTracks(errors);
- const filteredTracks = handleInitialTracks(initialOptions, tracks);
+ return tr;
+ }).then(tr => {
+ this._initDeviceList(true);
- setGUMPendingStateOnFailedTracks(filteredTracks);
+ const filteredTracks = handleInitialTracks(initialOptions, tr);
- return this.startConference(con, filteredTracks);
- },
+ setGUMPendingStateOnFailedTracks(filteredTracks);
- /**
- * Joins conference after the tracks have been configured in the prejoin screen.
- *
- * @param {Object[]} tracks - An array with the configured tracks
- * @returns {void}
- */
- async prejoinStart(tracks) {
- if (!_connectionPromise) {
- // The conference object isn't initialized yet. Wait for the promise to initialise.
- await new Promise(resolve => {
- _onConnectionPromiseCreated = resolve;
- });
- _onConnectionPromiseCreated = undefined;
- }
-
- let con;
-
- try {
- con = await _connectionPromise;
- this.startConference(con, tracks);
- } catch (error) {
- logger.error(`An error occurred while trying to join a meeting from the prejoin screen: ${error}`);
- APP.store.dispatch(setJoiningInProgress(false));
- }
+ return filteredTracks;
+ }),
+ APP.store.dispatch(connect())
+ ]).then(([ tracks, _ ]) => {
+ this.startConference(tracks).catch(logger.error);
+ });
},
/**
@@ -1413,9 +1240,7 @@ export default {
* Used by the Breakout Rooms feature to join a breakout room or go back to the main room.
*/
async joinRoom(roomName, options) {
- // Reset VideoLayout. It's destroyed in features/video-layout/middleware.web.js so re-initialize it.
- VideoLayout.initLargeVideo();
- VideoLayout.resizeVideoArea();
+ APP.store.dispatch(conferenceWillInit());
// Restore initial state.
this._localTracksInitialized = false;
@@ -1440,7 +1265,7 @@ export default {
},
_createRoom(localTracks) {
- room = connection.initJitsiConference(APP.conference.roomName, this._getConferenceOptions());
+ room = APP.connection.initJitsiConference(APP.conference.roomName, this._getConferenceOptions());
// Filter out the tracks that are muted (except on Safari).
const tracks = browser.isWebKitBased() ? localTracks : localTracks.filter(track => !track.isMuted());
@@ -1787,10 +1612,10 @@ export default {
titleKey = 'notify.screenShareNoAudioTitle';
}
- APP.UI.messageHandler.showError({
+ APP.store.dispatch(showErrorNotification({
descriptionKey,
titleKey
- });
+ }, NOTIFICATION_TIMEOUT_TYPE.LONG));
},
/**
@@ -2184,21 +2009,6 @@ export default {
this.hangup(true);
});
- // logout
- APP.UI.addListener(UIEvents.LOGOUT, () => {
- AuthHandler.logout(room).then(url => {
- if (url) {
- UIUtil.redirect(url);
- } else {
- this.hangup(true);
- }
- });
- });
-
- APP.UI.addListener(UIEvents.AUTH_CLICKED, () => {
- AuthHandler.authenticate(room);
- });
-
APP.UI.addListener(
UIEvents.VIDEO_DEVICE_CHANGED,
cameraDeviceId => {
diff --git a/connection.js b/connection.js
deleted file mode 100644
index 3456a97da2..0000000000
--- a/connection.js
+++ /dev/null
@@ -1,209 +0,0 @@
-/* global APP, JitsiMeetJS, config */
-
-import { jitsiLocalStorage } from '@jitsi/js-utils';
-import Logger from '@jitsi/logger';
-
-import { redirectToTokenAuthService } from './modules/UI/authentication/AuthHandler';
-import { LoginDialog } from './react/features/authentication/components';
-import { isTokenAuthEnabled } from './react/features/authentication/functions';
-import {
- connectionEstablished,
- connectionFailed,
- constructOptions
-} from './react/features/base/connection/actions.web';
-import { openDialog } from './react/features/base/dialog/actions';
-import { setJWT } from './react/features/base/jwt/actions';
-import {
- JitsiConnectionErrors,
- JitsiConnectionEvents
-} from './react/features/base/lib-jitsi-meet';
-import { isFatalJitsiConnectionError } from './react/features/base/lib-jitsi-meet/functions';
-import { getCustomerDetails } from './react/features/jaas/actions.any';
-import { getJaasJWT, isVpaasMeeting } from './react/features/jaas/functions';
-import {
- setPrejoinDisplayNameRequired
-} from './react/features/prejoin/actions';
-const logger = Logger.getLogger(__filename);
-
-/**
- * The feature announced so we can distinguish jibri participants.
- *
- * @type {string}
- */
-export const DISCO_JIBRI_FEATURE = 'http://jitsi.org/protocol/jibri';
-
-/**
- * Try to open connection using provided credentials.
- * @param {string} [id]
- * @param {string} [password]
- * @returns {Promise<JitsiConnection>} connection if
- * everything is ok, else error.
- */
-export async function connect(id, password) {
- const state = APP.store.getState();
- let { jwt } = state['features/base/jwt'];
- const { iAmRecorder, iAmSipGateway } = state['features/base/config'];
-
- if (!iAmRecorder && !iAmSipGateway && isVpaasMeeting(state)) {
- await APP.store.dispatch(getCustomerDetails());
-
- if (!jwt) {
- jwt = await getJaasJWT(state);
- APP.store.dispatch(setJWT(jwt));
- }
- }
-
- const connection = new JitsiMeetJS.JitsiConnection(null, jwt, constructOptions(state));
-
- if (config.iAmRecorder) {
- connection.addFeature(DISCO_JIBRI_FEATURE);
- }
-
- return new Promise((resolve, reject) => {
- connection.addEventListener(
- JitsiConnectionEvents.CONNECTION_ESTABLISHED,
- handleConnectionEstablished);
- connection.addEventListener(
- JitsiConnectionEvents.CONNECTION_FAILED,
- handleConnectionFailed);
- connection.addEventListener(
- JitsiConnectionEvents.CONNECTION_FAILED,
- connectionFailedHandler);
- connection.addEventListener(
- JitsiConnectionEvents.DISPLAY_NAME_REQUIRED,
- displayNameRequiredHandler
- );
-
- /* eslint-disable max-params */
- /**
- *
- */
- function connectionFailedHandler(error, message, credentials, details) {
- /* eslint-enable max-params */
- APP.store.dispatch(
- connectionFailed(
- connection, {
- credentials,
- details,
- message,
- name: error
- }));
-
- if (isFatalJitsiConnectionError(error)) {
- connection.removeEventListener(
- JitsiConnectionEvents.CONNECTION_FAILED,
- connectionFailedHandler);
- }
- }
-
- /**
- *
- */
- function unsubscribe() {
- connection.removeEventListener(
- JitsiConnectionEvents.CONNECTION_ESTABLISHED,
- handleConnectionEstablished);
- connection.removeEventListener(
- JitsiConnectionEvents.CONNECTION_FAILED,
- handleConnectionFailed);
- }
-
- /**
- *
- */
- function handleConnectionEstablished() {
- APP.store.dispatch(connectionEstablished(connection, Date.now()));
- unsubscribe();
- resolve(connection);
- }
-
- /**
- *
- */
- function handleConnectionFailed(err) {
- unsubscribe();
- logger.error('CONNECTION FAILED:', err);
- reject(err);
- }
-
- /**
- * Marks the display name for the prejoin screen as required.
- * This can happen if a user tries to join a room with lobby enabled.
- */
- function displayNameRequiredHandler() {
- APP.store.dispatch(setPrejoinDisplayNameRequired());
- }
-
- connection.connect({
- id,
- password
- });
- });
-}
-
-/**
- * Open JitsiConnection using provided credentials.
- * If retry option is true it will show auth dialog on PASSWORD_REQUIRED error.
- *
- * @param {object} options
- * @param {string} [options.id]
- * @param {string} [options.password]
- * @param {string} [options.roomName]
- * @param {boolean} [retry] if we should show auth dialog
- * on PASSWORD_REQUIRED error.
- *
- * @returns {Promise<JitsiConnection>}
- */
-export function openConnection({ id, password, retry, roomName }) {
- const usernameOverride
- = jitsiLocalStorage.getItem('xmpp_username_override');
- const passwordOverride
- = jitsiLocalStorage.getItem('xmpp_password_override');
-
- if (usernameOverride && usernameOverride.length > 0) {
- id = usernameOverride; // eslint-disable-line no-param-reassign
- }
- if (passwordOverride && passwordOverride.length > 0) {
- password = passwordOverride; // eslint-disable-line no-param-reassign
- }
-
- return connect(id, password).catch(err => {
- if (retry) {
- const { jwt } = APP.store.getState()['features/base/jwt'];
-
- if (err === JitsiConnectionErrors.PASSWORD_REQUIRED && !jwt) {
- return requestAuth(roomName);
- }
- }
-
- throw err;
- });
-}
-
-/**
- * Show Authentication Dialog and try to connect with new credentials.
- * If failed to connect because of PASSWORD_REQUIRED error
- * then ask for password again.
- * @param {string} [roomName] name of the conference room
- *
- * @returns {Promise<JitsiConnection>}
- */
-function requestAuth(roomName) {
- const config = APP.store.getState()['features/base/config'];
-
- if (isTokenAuthEnabled(config)) {
- // This Promise never resolves as user gets redirected to another URL
- return new Promise(() => redirectToTokenAuthService(roomName));
- }
-
- return new Promise(resolve => {
- const onSuccess = connection => {
- resolve(connection);
- };
-
- APP.store.dispatch(
- openDialog(LoginDialog, { onSuccess,
- roomName })
- );
- });
-}
diff --git a/lang/main.json b/lang/main.json
index 6cdfcd5a08..ef6b7a0f97 100644
--- a/lang/main.json
+++ b/lang/main.json
@@ -370,8 +370,6 @@
"permissionCameraRequiredError": "Camera permission is required to participate in conferences with video. Please grant it in Settings",
"permissionErrorTitle": "Permission required",
"permissionMicRequiredError": "Microphone permission is required to participate in conferences with audio. Please grant it in Settings",
- "popupError": "Your browser is blocking pop-up windows from this site. Please enable pop-ups in your browser's security settings and try again.",
- "popupErrorTitle": "Pop-up blocked",
"readMore": "more",
"recentlyUsedObjects": "Your recently used objects",
"recording": "Recording",
@@ -439,6 +437,7 @@
"token": "token",
"tokenAuthFailed": "Sorry, you're not allowed to join this call.",
"tokenAuthFailedTitle": "Authentication failed",
+ "tokenAuthUnsupported": "Token URL is not supported.",
"transcribing": "Transcribing",
"unlockRoom": "Remove meeting $t(lockRoomPassword)",
"user": "User",
diff --git a/modules/UI/UI.js b/modules/UI/UI.js
index 379a03ba92..92c4c1cf23 100644
--- a/modules/UI/UI.js
+++ b/modules/UI/UI.js
@@ -6,6 +6,9 @@ const UI = {};
import Logger from '@jitsi/logger';
import EventEmitter from 'events';
+import {
+ conferenceWillInit
+} from '../../react/features/base/conference/actions';
import { isMobileBrowser } from '../../react/features/base/environment/utils';
import { setColorAlpha } from '../../react/features/base/util/helpers';
import { setDocumentUrl } from '../../react/features/etherpad/actions';
@@ -24,14 +27,11 @@ import {
import UIEvents from '../../service/UI/UIEvents';
import EtherpadManager from './etherpad/Etherpad';
-import messageHandler from './util/MessageHandler';
import UIUtil from './util/UIUtil';
import VideoLayout from './videolayout/VideoLayout';
const logger = Logger.getLogger(__filename);
-UI.messageHandler = messageHandler;
-
const eventEmitter = new EventEmitter();
UI.eventEmitter = eventEmitter;
@@ -58,30 +58,6 @@ UI.isFullScreen = function() {
return UIUtil.isFullScreen();
};
-/**
- * Notify user that server has shut down.
- */
-UI.notifyGracefulShutdown = function() {
- messageHandler.showError({
- descriptionKey: 'dialog.gracefulShutdown',
- titleKey: 'dialog.serviceUnavailable'
- });
-};
-
-/**
- * Notify user that reservation error happened.
- */
-UI.notifyReservationError = function(code, msg) {
- messageHandler.showError({
- descriptionArguments: {
- code,
- msg
- },
- descriptionKey: 'dialog.reservationErrorMsg',
- titleKey: 'dialog.reservationError'
- });
-};
-
/**
* Initialize conference UI.
*/
@@ -91,18 +67,9 @@ UI.initConference = function() {
/**
* Starts the UI module and initializes all related components.
- *
- * @returns {boolean} true if the UI is ready and the conference should be
- * established, false - otherwise (for example in the case of welcome page)
*/
UI.start = function() {
- VideoLayout.initLargeVideo();
-
- // Do not animate the video area on UI start (second argument passed into
- // resizeVideoArea) because the animation is not visible anyway. Plus with
- // the current dom layout, the quality label is part of the video layout and
- // will be seen animating in.
- VideoLayout.resizeVideoArea();
+ APP.store.dispatch(conferenceWillInit());
if (isMobileBrowser()) {
document.body.classList.add('mobile-browser');
@@ -292,40 +259,6 @@ UI.showToolbar = timeout => APP.store.dispatch(showToolbox(timeout));
// Used by torture.
UI.dockToolbar = dock => APP.store.dispatch(dockToolbox(dock));
-/**
- * Notify user that connection failed.
- * @param {string} stropheErrorMsg raw Strophe error message
- */
-UI.notifyConnectionFailed = function(stropheErrorMsg) {
- let descriptionKey;
- let descriptionArguments;
-
- if (stropheErrorMsg) {
- descriptionKey = 'dialog.connectErrorWithMsg';
- descriptionArguments = { msg: stropheErrorMsg };
- } else {
- descriptionKey = 'dialog.connectError';
- }
-
- messageHandler.showError({
- descriptionArguments,
- descriptionKey,
- titleKey: 'connection.CONNFAIL'
- });
-};
-
-
-/**
- * Notify user that maximum users limit has been reached.
- */
-UI.notifyMaxUsersLimitReached = function() {
- messageHandler.showError({
- hideErrorSupportLink: true,
- descriptionKey: 'dialog.maxUsersLimitReached',
- titleKey: 'dialog.maxUsersLimitReachedTitle'
- });
-};
-
UI.handleLastNEndpoints = function(leavingIds, enteringIds) {
VideoLayout.onLastNEndpointsChanged(leavingIds, enteringIds);
};
@@ -337,13 +270,6 @@ UI.handleLastNEndpoints = function(leavingIds, enteringIds) {
*/
UI.setAudioLevel = (id, lvl) => VideoLayout.setAudioLevel(id, lvl);
-UI.notifyTokenAuthFailed = function() {
- messageHandler.showError({
- descriptionKey: 'dialog.tokenAuthFailed',
- titleKey: 'dialog.tokenAuthFailedTitle'
- });
-};
-
/**
* Update list of available physical devices.
*/
diff --git a/modules/UI/authentication/AuthHandler.js b/modules/UI/authentication/AuthHandler.js
deleted file mode 100644
index 4b59d94ff0..0000000000
--- a/modules/UI/authentication/AuthHandler.js
+++ /dev/null
@@ -1,227 +0,0 @@
-/* global APP */
-import Logger from '@jitsi/logger';
-
-import { openConnection } from '../../../connection';
-import {
- openAuthDialog,
- openLoginDialog } from '../../../react/features/authentication/actions.web';
-import {
- LoginDialog,
- WaitForOwnerDialog
-} from '../../../react/features/authentication/components';
-import {
- getTokenAuthUrl,
- isTokenAuthEnabled
-} from '../../../react/features/authentication/functions';
-import { getReplaceParticipant } from '../../../react/features/base/config/functions';
-import { isDialogOpen } from '../../../react/features/base/dialog/functions';
-import { setJWT } from '../../../react/features/base/jwt/actions';
-import UIUtil from '../util/UIUtil';
-
-import ExternalLoginDialog from './LoginDialog';
-
-
-let externalAuthWindow;
-
-const logger = Logger.getLogger(__filename);
-
-
-/**
- * Authenticate using external service or just focus
- * external auth window if there is one already.
- *
- * @param {JitsiConference} room
- * @param {string} [lockPassword] password to use if the conference is locked
- */
-function doExternalAuth(room, lockPassword) {
- const config = APP.store.getState()['features/base/config'];
-
- if (externalAuthWindow) {
- externalAuthWindow.focus();
-
- return;
- }
-
- if (room.isJoined()) {
- let getUrl;
-
- if (isTokenAuthEnabled(config)) {
- getUrl = Promise.resolve(getTokenAuthUrl(config)(room.getName(), true));
- initJWTTokenListener(room);
- } else {
- getUrl = room.getExternalAuthUrl(true);
- }
- getUrl.then(url => {
- externalAuthWindow = ExternalLoginDialog.showExternalAuthDialog(
- url,
- () => {
- externalAuthWindow = null;
- if (!isTokenAuthEnabled(config)) {
- room.join(lockPassword);
- }
- }
- );
- });
- } else if (isTokenAuthEnabled(config)) {
- redirectToTokenAuthService(room.getName());
- } else {
- room.getExternalAuthUrl().then(UIUtil.redirect);
- }
-}
-
-/**
- * Redirect the user to the token authentication service for the login to be
- * performed. Once complete it is expected that the service will bring the user
- * back with "?jwt={the JWT token}" query parameter added.
- * @param {string} [roomName] the name of the conference room.
- */
-export function redirectToTokenAuthService(roomName) {
- const config = APP.store.getState()['features/base/config'];
-
- // FIXME: This method will not preserve the other URL params that were
- // originally passed.
- UIUtil.redirect(getTokenAuthUrl(config)(roomName, false));
-}
-
-/**
- * Initializes 'message' listener that will wait for a JWT token to be received
- * from the token authentication service opened in a popup window.
- * @param room the name of the conference room.
- */
-function initJWTTokenListener(room) {
- /**
- *
- */
- function listener({ data, source }) {
- if (externalAuthWindow !== source) {
- logger.warn('Ignored message not coming '
- + 'from external authnetication window');
-
- return;
- }
-
- let jwt;
-
- if (data && (jwt = data.jwtToken)) {
- logger.info('Received JSON Web Token (JWT):', jwt);
-
- APP.store.dispatch(setJWT(jwt));
-
- const roomName = room.getName();
-
- openConnection({
- retry: false,
- roomName
- }).then(connection => {
- // Start new connection
- const newRoom = connection.initJitsiConference(
- roomName, APP.conference._getConferenceOptions());
-
- // Authenticate from the new connection to get
- // the session-ID from the focus, which will then be used
- // to upgrade current connection's user role
-
- newRoom.room.moderator.authenticate()
- .then(() => {
- connection.disconnect();
-
- // At this point we'll have session-ID stored in
- // the settings. It will be used in the call below
- // to upgrade user's role
- room.room.moderator.authenticate()
- .then(() => {
- logger.info('User role upgrade done !');
- // eslint-disable-line no-use-before-define
- unregister();
- })
- .catch((err, errCode) => {
- logger.error('Authentication failed: ',
- err, errCode);
- unregister();
- });
- })
- .catch((error, code) => {
- unregister();
- connection.disconnect();
- logger.error(
- 'Authentication failed on the new connection',
- error, code);
- });
- }, err => {
- unregister();
- logger.error('Failed to open new connection', err);
- });
- }
- }
-
- /**
- *
- */
- function unregister() {
- window.removeEventListener('message', listener);
- }
-
- if (window.addEventListener) {
- window.addEventListener('message', listener, false);
- }
-}
-
-/**
- * Authenticate for the conference.
- * Uses external service for auth if conference supports that.
- * @param {JitsiConference} room
- * @param {string} [lockPassword] password to use if the conference is locked
- */
-function authenticate(room, lockPassword) {
- const config = APP.store.getState()['features/base/config'];
-
- if (isTokenAuthEnabled(config) || room.isExternalAuthEnabled()) {
- doExternalAuth(room, lockPassword);
- } else {
- APP.store.dispatch(openLoginDialog());
- }
-}
-
-/**
- * Notify user that authentication is required to create the conference.
- * @param {JitsiConference} room
- * @param {string} [lockPassword] password to use if the conference is locked
- */
-function requireAuth(room, lockPassword) {
- if (isDialogOpen(APP.store, WaitForOwnerDialog) || isDialogOpen(APP.store, LoginDialog)) {
- return;
- }
-
- APP.store.dispatch(
- openAuthDialog(
- room.getName(), authenticate.bind(null, room, lockPassword))
- );
-}
-
-/**
- * De-authenticate local user.
- *
- * @param {JitsiConference} room
- * @param {string} [lockPassword] password to use if the conference is locked
- * @returns {Promise}
- */
-function logout(room) {
- return new Promise(resolve => {
- room.room.moderator.logout(resolve);
- }).then(url => {
- // de-authenticate conference on the fly
- if (room.isJoined()) {
- const replaceParticipant = getReplaceParticipant(APP.store.getState());
-
- room.join(null, replaceParticipant);
- }
-
- return url;
- });
-}
-
-export default {
- authenticate,
- logout,
- requireAuth
-};
diff --git a/modules/UI/authentication/LoginDialog.js b/modules/UI/authentication/LoginDialog.js
deleted file mode 100644
index e91e9a04ba..0000000000
--- a/modules/UI/authentication/LoginDialog.js
+++ /dev/null
@@ -1,28 +0,0 @@
-/* global APP */
-
-export default {
-
- /**
- * Show notification that external auth is required (using provided url).
- * @param {string} url - URL to use for external auth.
- * @param {function} callback - callback to invoke when auth popup is closed.
- * @returns auth dialog
- */
- showExternalAuthDialog(url, callback) {
- const dialog = APP.UI.messageHandler.openCenteredPopup(
- url, 910, 660,
-
- // On closed
- callback
- );
-
- if (!dialog) {
- APP.UI.messageHandler.showWarning({
- descriptionKey: 'dialog.popupError',
- titleKey: 'dialog.popupErrorTitle'
- });
- }
-
- return dialog;
- }
-};
diff --git a/modules/UI/util/MessageHandler.js b/modules/UI/util/MessageHandler.js
deleted file mode 100644
index cb221e6dcb..0000000000
--- a/modules/UI/util/MessageHandler.js
+++ /dev/null
@@ -1,61 +0,0 @@
-/* global APP */
-
-import { showErrorNotification, showWarningNotification } from '../../../react/features/notifications/actions';
-import { NOTIFICATION_TIMEOUT_TYPE } from '../../../react/features/notifications/constants';
-
-const messageHandler = {
- /**
- * Opens new popup window for given <tt>url</tt> centered over current
- * window.
- *
- * @param url the URL to be displayed in the popup window
- * @param w the width of the popup window
- * @param h the height of the popup window
- * @param onPopupClosed optional callback function called when popup window
- * has been closed.
- *
- * @returns {object} popup window object if opened successfully or undefined
- * in case we failed to open it(popup blocked)
- */
- // eslint-disable-next-line max-params
- openCenteredPopup(url, w, h, onPopupClosed) {
- const l = window.screenX + (window.innerWidth / 2) - (w / 2);
- const t = window.screenY + (window.innerHeight / 2) - (h / 2);
- const popup = window.open(
- url, '_blank',
- String(`top=${t}, left=${l}, width=${w}, height=${h}`));
-
- if (popup && onPopupClosed) {
- const pollTimer = window.setInterval(() => {
- if (popup.closed !== false) {
- window.clearInterval(pollTimer);
- onPopupClosed();
- }
- }, 200);
- }
-
- return popup;
- },
-
- /**
- * Shows an error dialog to the user.
- *
- * @param {object} props - The properties to pass to the
- * showErrorNotification action.
- */
- showError(props) {
- APP.store.dispatch(showErrorNotification(props, NOTIFICATION_TIMEOUT_TYPE.LONG));
- },
-
- /**
- * Shows a warning dialog to the user.
- *
- * @param {object} props - The properties to pass to the
- * showWarningNotification action.
- */
- showWarning(props) {
- APP.store.dispatch(showWarningNotification(props, NOTIFICATION_TIMEOUT_TYPE.LONG));
- }
-};
-
-export default messageHandler;
diff --git a/modules/UI/util/UIUtil.js b/modules/UI/util/UIUtil.js
index 9c4788ea8b..1ed4b6e23e 100644
--- a/modules/UI/util/UIUtil.js
+++ b/modules/UI/util/UIUtil.js
@@ -31,18 +31,6 @@ const UIUtil = {
return result;
},
- /**
- * Redirects to a given URL.
- *
- * @param {string} url - The redirect URL.
- * NOTE: Currently used to redirect to 3rd party location for
- * authentication. In most cases redirectWithStoredParams action must be
- * used instead of this method in order to preserve current URL params.
- */
- redirect(url) {
- window.location.href = url;
- },
-
/**
* Indicates if we're currently in full screen mode.
*
diff --git a/react/features/app/middlewares.any.ts b/react/features/app/middlewares.any.ts
index a975e16cb5..0399e3e6c9 100644
--- a/react/features/app/middlewares.any.ts
+++ b/react/features/app/middlewares.any.ts
@@ -1,4 +1,5 @@
import '../analytics/middleware';
+import '../authentication/middleware';
import '../av-moderation/middleware';
import '../base/conference/middleware';
import '../base/config/middleware';
diff --git a/react/features/app/middlewares.native.ts b/react/features/app/middlewares.native.ts
index b9fcf5cc4f..4e1aa7e712 100644
--- a/react/features/app/middlewares.native.ts
+++ b/react/features/app/middlewares.native.ts
@@ -1,4 +1,3 @@
-import '../authentication/middleware';
import '../dynamic-branding/middleware';
import '../gifs/middleware';
import '../mobile/audio-mode/middleware';
diff --git a/react/features/app/middlewares.web.ts b/react/features/app/middlewares.web.ts
index 78d9de84b7..41e11edeb9 100644
--- a/react/features/app/middlewares.web.ts
+++ b/react/features/app/middlewares.web.ts
@@ -1,4 +1,4 @@
-import '../authentication/middleware';
+import '../base/connection/middleware';
import '../base/i18n/middleware';
import '../base/devices/middleware';
import '../base/media/middleware';
diff --git a/react/features/authentication/actionTypes.ts b/react/features/authentication/actionTypes.ts
index dc56b051da..b8c526f32b 100644
--- a/react/features/authentication/actionTypes.ts
+++ b/react/features/authentication/actionTypes.ts
@@ -8,6 +8,24 @@
*/
export const CANCEL_LOGIN = 'CANCEL_LOGIN';
+/**
+ * The type of (redux) action which signals to login.
+ *
+ * {
+ * type: LOGOUT
+ * }
+ */
+export const LOGIN = 'LOGIN';
+
+/**
+ * The type of (redux) action which signals to logout.
+ *
+ * {
+ * type: LOGOUT
+ * }
+ */
+export const LOGOUT = 'LOGOUT';
+
/**
* The type of (redux) action which signals that the cyclic operation of waiting
* for conference owner has been aborted.
diff --git a/react/features/authentication/actions.any.ts b/react/features/authentication/actions.any.ts
index fbcfb4499f..27a1d7599e 100644
--- a/react/features/authentication/actions.any.ts
+++ b/react/features/authentication/actions.any.ts
@@ -1,7 +1,7 @@
import { IStore } from '../app/types';
import { checkIfCanJoin } from '../base/conference/actions';
import { IJitsiConference } from '../base/conference/reducer';
-import { openDialog } from '../base/dialog/actions';
+import { hideDialog, openDialog } from '../base/dialog/actions';
import {
STOP_WAIT_FOR_OWNER,
@@ -126,6 +126,16 @@ function _upgradeRoleStarted(thenableWithCancel: Object) {
};
}
+/**
+ * Hides an authentication dialog where the local participant
+ * should authenticate.
+ *
+ * @returns {Function}.
+ */
+export function hideLoginDialog() {
+ return hideDialog(LoginDialog);
+}
+
/**
* Opens {@link WaitForOnwerDialog}.
*
diff --git a/react/features/authentication/actions.native.ts b/react/features/authentication/actions.native.ts
index 4890a3e9fc..b958a18dbd 100644
--- a/react/features/authentication/actions.native.ts
+++ b/react/features/authentication/actions.native.ts
@@ -1,4 +1,4 @@
-import { appNavigate } from '../app/actions';
+import { appNavigate } from '../app/actions.native';
import { IStore } from '../app/types';
import { conferenceLeft } from '../base/conference/actions';
import { connectionFailed } from '../base/connection/actions.native';
@@ -61,4 +61,11 @@ export function cancelWaitForOwner() {
};
}
-
+/** .
+ * Redirect to the default location (e.g. Welcome page).
+ *
+ * @returns {Function}
+ */
+export function redirectToDefaultLocation() {
+ return (dispatch: IStore['dispatch']) => dispatch(appNavigate(undefined));
+}
diff --git a/react/features/authentication/actions.web.ts b/react/features/authentication/actions.web.ts
index 4d0fd50e93..3b61835035 100644
--- a/react/features/authentication/actions.web.ts
+++ b/react/features/authentication/actions.web.ts
@@ -1,12 +1,11 @@
import { maybeRedirectToWelcomePage } from '../app/actions.web';
import { IStore } from '../app/types';
-import { hideDialog, openDialog } from '../base/dialog/actions';
import {
- CANCEL_LOGIN
+ CANCEL_LOGIN,
+ LOGIN,
+ LOGOUT
} from './actionTypes';
-import LoginDialog from './components/web/LoginDialog';
-import WaitForOwnerDialog from './components/web/WaitForOwnerDialog';
export * from './actions.any';
@@ -35,31 +34,37 @@ export function cancelWaitForOwner() {
};
}
-/**
- * Hides a authentication dialog where the local participant
- * should authenticate.
+/** .
+ * Redirect to the default location (e.g. Welcome page).
*
- * @returns {Function}.
+ * @returns {Function}
*/
-export function hideLoginDialog() {
- return hideDialog(LoginDialog);
+export function redirectToDefaultLocation() {
+ return (dispatch: IStore['dispatch']) => dispatch(maybeRedirectToWelcomePage());
}
/**
- * Shows a notification dialog that authentication is required to create the.
- * Conference.
- * This is used for external auth.
+ * Login.
*
- * @param {string} room - The room name.
- * @param {Function} onAuthNow - The function to be invoked when external authentication.
- *
- * @returns {Function}.
+ * @returns {{
+ * type: LOGIN
+ * }}
*/
-export function openAuthDialog(room: String, onAuthNow?: Function) {
- return openDialog(WaitForOwnerDialog, {
- room,
- onAuthNow
- });
+export function login() {
+ return {
+ type: LOGIN
+ };
}
-
+/**
+ * Logout.
+ *
+ * @returns {{
+ * type: LOGOUT
+ * }}
+ */
+export function logout() {
+ return {
+ type: LOGOUT
+ };
+}
diff --git a/react/features/authentication/components/web/LoginDialog.tsx b/react/features/authentication/components/web/LoginDialog.tsx
index a867f513c8..00ff3de22a 100644
--- a/react/features/authentication/components/web/LoginDialog.tsx
+++ b/react/features/authentication/components/web/LoginDialog.tsx
@@ -2,11 +2,10 @@ import React, { Component } from 'react';
import { WithTranslation } from 'react-i18next';
import { connect as reduxConnect } from 'react-redux';
-// @ts-expect-error
-import { connect } from '../../../../../connection';
import { IReduxState, IStore } from '../../../app/types';
import { IJitsiConference } from '../../../base/conference/reducer';
import { IConfig } from '../../../base/config/configType';
+import { connect } from '../../../base/connection/actions.web';
import { toJid } from '../../../base/connection/functions';
import { translate, translateToHTML } from '../../../base/i18n/functions';
import { JitsiConnectionErrors } from '../../../base/lib-jitsi-meet';
@@ -54,11 +53,6 @@ interface IProps extends WithTranslation {
*/
dispatch: IStore['dispatch'];
- /**
- * Invoked when username and password are submitted.
- */
- onSuccess: Function;
-
/**
* Conference room name.
*/
@@ -70,11 +64,6 @@ interface IProps extends WithTranslation {
*/
interface IState {
- /**
- * Authentication process starts before joining the conference room.
- */
- loginStarted: boolean;
-
/**
* The user entered password for the conference.
*/
@@ -102,8 +91,7 @@ class LoginDialog extends Component<IProps, IState> {
this.state = {
username: '',
- password: '',
- loginStarted: false
+ password: ''
};
this._onCancelLogin = this._onCancelLogin.bind(this);
@@ -135,8 +123,6 @@ class LoginDialog extends Component<IProps, IState> {
const {
_conference: conference,
_configHosts: configHosts,
- roomName,
- onSuccess,
dispatch
} = this.props;
const { password, username } = this.state;
@@ -148,19 +134,7 @@ class LoginDialog extends Component<IProps, IState> {
if (conference) {
dispatch(authenticateAndUpgradeRole(jid, password, conference));
} else {
- this.setState({
- loginStarted: true
- });
-
- connect(jid, password, roomName)
- .then((connection: any) => {
- onSuccess?.(connection);
- })
- .catch(() => {
- this.setState({
- loginStarted: false
- });
- });
+ dispatch(connect(jid, password));
}
}
@@ -249,7 +223,7 @@ class LoginDialog extends Component<IProps, IState> {
_connecting: connecting,
t
} = this.props;
- const { password, loginStarted, username } = this.state;
+ const { password, username } = this.state;
return (
<Dialog
@@ -258,7 +232,6 @@ class LoginDialog extends Component<IProps, IState> {
hideCloseButton = { true }
ok = {{
disabled: connecting
- || loginStarted
|| !password
|| !username,
translationKey: 'dialog.login'
@@ -315,7 +288,7 @@ function mapStateToProps(state: IReduxState) {
return {
_conference: authRequired || conference,
_configHosts: configHosts,
- _connecting: connecting || thenableWithCancel,
+ _connecting: Boolean(connecting) || Boolean(thenableWithCancel),
_error: connectionError || authenticateAndUpgradeRoleError,
_progress: progress
};
diff --git a/react/features/authentication/components/web/WaitForOwnerDialog.tsx b/react/features/authentication/components/web/WaitForOwnerDialog.tsx
index 48ef7431f5..f55229a26e 100644
--- a/react/features/authentication/components/web/WaitForOwnerDialog.tsx
+++ b/react/features/authentication/components/web/WaitForOwnerDialog.tsx
@@ -5,7 +5,7 @@ import { connect } from 'react-redux';
import { IStore } from '../../../app/types';
import { translate } from '../../../base/i18n/functions';
import Dialog from '../../../base/ui/components/web/Dialog';
-import { cancelWaitForOwner } from '../../actions.web';
+import { cancelWaitForOwner, login } from '../../actions.web';
/**
* The type of the React {@code Component} props of {@link WaitForOwnerDialog}.
@@ -16,11 +16,6 @@ interface IProps extends WithTranslation {
* Redux store dispatch method.
*/
dispatch: IStore['dispatch'];
-
- /**
- * Function to be invoked after click.
- */
- onAuthNow?: Function;
}
/**
@@ -61,9 +56,7 @@ class WaitForOwnerDialog extends PureComponent<IProps> {
* @returns {void}
*/
_onIAmHost() {
- const { onAuthNow } = this.props;
-
- onAuthNow?.();
+ this.props.dispatch(login());
}
/**
diff --git a/react/features/authentication/middleware.native.ts b/react/features/authentication/middleware.ts
similarity index 64%
rename from react/features/authentication/middleware.native.ts
rename to react/features/authentication/middleware.ts
index 6616fd2018..c4f9e5660a 100644
--- a/react/features/authentication/middleware.native.ts
+++ b/react/features/authentication/middleware.ts
@@ -1,4 +1,3 @@
-import { appNavigate } from '../app/actions.native';
import { IStore } from '../app/types';
import {
CONFERENCE_FAILED,
@@ -6,6 +5,7 @@ import {
CONFERENCE_LEFT
} from '../base/conference/actionTypes';
import { CONNECTION_ESTABLISHED, CONNECTION_FAILED } from '../base/connection/actionTypes';
+import { hangup } from '../base/connection/actions';
import { hideDialog } from '../base/dialog/actions';
import { isDialogOpen } from '../base/dialog/functions';
import {
@@ -13,19 +13,28 @@ import {
JitsiConnectionErrors
} from '../base/lib-jitsi-meet';
import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';
+import { getBackendSafeRoomName } from '../base/util/uri';
+import { showErrorNotification } from '../notifications/actions';
+import { NOTIFICATION_TIMEOUT_TYPE } from '../notifications/constants';
+import { openLogoutDialog } from '../settings/actions';
import {
CANCEL_LOGIN,
+ LOGIN,
+ LOGOUT,
STOP_WAIT_FOR_OWNER,
UPGRADE_ROLE_FINISHED,
WAIT_FOR_OWNER
} from './actionTypes';
import {
+ hideLoginDialog,
openLoginDialog,
openWaitForOwnerDialog,
+ redirectToDefaultLocation,
stopWaitForOwner,
- waitForOwner } from './actions.native';
+ waitForOwner } from './actions';
import { LoginDialog, WaitForOwnerDialog } from './components';
+import { getTokenAuthUrl, isTokenAuthEnabled } from './functions';
/**
* Middleware that captures connection or conference failed errors and controls
@@ -40,7 +49,8 @@ MiddlewareRegistry.register(store => next => action => {
switch (action.type) {
case CANCEL_LOGIN: {
const { dispatch, getState } = store;
- const { thenableWithCancel } = getState()['features/authentication'];
+ const state = getState();
+ const { thenableWithCancel } = state['features/authentication'];
thenableWithCancel?.cancel();
@@ -57,10 +67,8 @@ MiddlewareRegistry.register(store => next => action => {
return result;
}
- // Go back to the app's entry point.
- _hideLoginDialog(store);
+ dispatch(hideLoginDialog());
- const state = getState();
const { authRequired, conference } = state['features/base/conference'];
const { passwordRequired } = state['features/base/connection'];
@@ -68,7 +76,7 @@ MiddlewareRegistry.register(store => next => action => {
// NOTE: Despite it's confusing name, `passwordRequired` implies an XMPP
// connection auth error.
if ((passwordRequired || authRequired) && !conference) {
- dispatch(appNavigate(undefined));
+ dispatch(redirectToDefaultLocation());
}
}
break;
@@ -100,7 +108,7 @@ MiddlewareRegistry.register(store => next => action => {
if (_isWaitingForOwner(store)) {
store.dispatch(stopWaitForOwner());
}
- _hideLoginDialog(store);
+ store.dispatch(hideLoginDialog());
break;
case CONFERENCE_LEFT:
@@ -108,18 +116,43 @@ MiddlewareRegistry.register(store => next => action => {
break;
case CONNECTION_ESTABLISHED:
- _hideLoginDialog(store);
+ store.dispatch(hideLoginDialog());
break;
case CONNECTION_FAILED: {
const { error } = action;
+ const state = store.getState();
+ const { jwt } = state['features/base/jwt'];
if (error
&& error.name === JitsiConnectionErrors.PASSWORD_REQUIRED
- && typeof error.recoverable === 'undefined') {
+ && typeof error.recoverable === 'undefined'
+ && !jwt) {
error.recoverable = true;
- store.dispatch(openLoginDialog());
+
+ _handleLogin(store);
+ }
+
+ break;
+ }
+
+ case LOGIN: {
+ _handleLogin(store);
+
+ break;
+ }
+
+ case LOGOUT: {
+ const { conference } = store.getState()['features/base/conference'];
+
+ if (!conference) {
+ break;
}
+
+ store.dispatch(openLogoutDialog(() =>
+ conference.room.moderator.logout(() => store.dispatch(hangup(true)))
+ ));
+
break;
}
@@ -132,7 +165,7 @@ MiddlewareRegistry.register(store => next => action => {
const { error, progress } = action;
if (!error && progress === 1) {
- _hideLoginDialog(store);
+ store.dispatch(hideLoginDialog());
}
break;
}
@@ -144,7 +177,7 @@ MiddlewareRegistry.register(store => next => action => {
action.waitForOwnerTimeoutID = setTimeout(handler, timeoutMs);
- // The WAIT_FOR_OWNER action is cyclic and we don't want to hide the
+ // The WAIT_FOR_OWNER action is cyclic, and we don't want to hide the
// login dialog every few seconds.
isDialogOpen(store, LoginDialog)
|| store.dispatch(openWaitForOwnerDialog());
@@ -162,22 +195,12 @@ MiddlewareRegistry.register(store => next => action => {
* @param {Object} store - The redux store.
* @returns {void}
*/
-function _clearExistingWaitForOwnerTimeout(
- { getState }: IStore) {
+function _clearExistingWaitForOwnerTimeout({ getState }: IStore) {
const { waitForOwnerTimeoutID } = getState()['features/authentication'];
waitForOwnerTimeoutID && clearTimeout(waitForOwnerTimeoutID);
}
-/**
- * Hides {@link LoginDialog} if it's currently displayed.
- *
- * @param {Object} store - The redux store.
- * @returns {void}
- */
-function _hideLoginDialog({ dispatch }: IStore) {
- dispatch(hideDialog(LoginDialog));
-}
/**
* Checks if the cyclic "wait for conference owner" task is currently scheduled.
@@ -188,3 +211,35 @@ function _hideLoginDialog({ dispatch }: IStore) {
function _isWaitingForOwner({ getState }: IStore) {
return Boolean(getState()['features/authentication'].waitForOwnerTimeoutID);
}
+
+/**
+ * Handles login challenge. Opens login dialog or redirects to token auth URL.
+ *
+ * @param {Store} store - The redux store in which the specified {@code action}
+ * is being dispatched.
+ * @returns {void}
+ */
+function _handleLogin({ dispatch, getState }: IStore) {
+ const state = getState();
+ const config = state['features/base/config'];
+ const room = getBackendSafeRoomName(state['features/base/conference'].room);
+
+ if (isTokenAuthEnabled(config)) {
+ if (typeof APP === 'undefined') {
+ dispatch(showErrorNotification({
+ descriptionKey: 'dialog.tokenAuthUnsupported',
+ titleKey: 'dialog.tokenAuthFailedTitle'
+ }, NOTIFICATION_TIMEOUT_TYPE.LONG));
+
+ dispatch(redirectToDefaultLocation());
+
+ return;
+ }
+
+ // FIXME: This method will not preserve the other URL params that were originally passed.
+ // redirectToTokenAuthService
+ window.location.href = getTokenAuthUrl(config)(room, false);
+ } else {
+ dispatch(openLoginDialog());
+ }
+}
diff --git a/react/features/authentication/middleware.web.ts b/react/features/authentication/middleware.web.ts
deleted file mode 100644
index 60649164c2..0000000000
--- a/react/features/authentication/middleware.web.ts
+++ /dev/null
@@ -1,152 +0,0 @@
-import { maybeRedirectToWelcomePage } from '../app/actions.web';
-import { IStore } from '../app/types';
-import {
- CONFERENCE_FAILED,
- CONFERENCE_JOINED,
- CONFERENCE_LEFT
-} from '../base/conference/actionTypes';
-import { CONNECTION_ESTABLISHED } from '../base/connection/actionTypes';
-import { hideDialog } from '../base/dialog/actions';
-import { isDialogOpen } from '../base/dialog/functions';
-import {
- JitsiConferenceErrors
-} from '../base/lib-jitsi-meet';
-import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';
-
-import {
- CANCEL_LOGIN,
- STOP_WAIT_FOR_OWNER,
- UPGRADE_ROLE_FINISHED,
- WAIT_FOR_OWNER
-} from './actionTypes';
-import {
- hideLoginDialog,
- openWaitForOwnerDialog,
- stopWaitForOwner
-} from './actions.web';
-import LoginDialog from './components/web/LoginDialog';
-import WaitForOwnerDialog from './components/web/WaitForOwnerDialog';
-
-/**
- * Middleware that captures connection or conference failed errors and controls
- * {@link WaitForOwnerDialog} and {@link LoginDialog}.
- *
- * FIXME Some of the complexity was introduced by the lack of dialog stacking.
- *
- * @param {Store} store - Redux store.
- * @returns {Function}
- */
-MiddlewareRegistry.register(store => next => action => {
- switch (action.type) {
-
- case CANCEL_LOGIN: {
- const { dispatch, getState } = store;
-
- if (!isDialogOpen(store, WaitForOwnerDialog)) {
- if (_isWaitingForOwner(store)) {
- dispatch(openWaitForOwnerDialog());
-
- return next(action);
- }
-
- dispatch(hideLoginDialog());
-
- const { authRequired, conference } = getState()['features/base/conference'];
- const { passwordRequired } = getState()['features/base/connection'];
-
- // Only end the meeting if we are not already inside and trying to upgrade.
- if ((authRequired && !conference) || passwordRequired) {
- dispatch(maybeRedirectToWelcomePage());
- }
- }
- break;
- }
-
- case CONFERENCE_FAILED: {
- const { error } = action;
- let recoverable;
-
- if (error.name === JitsiConferenceErrors.AUTHENTICATION_REQUIRED) {
- if (typeof error.recoverable === 'undefined') {
- error.recoverable = true;
- }
- recoverable = error.recoverable;
- }
- if (recoverable) {
- // we haven't migrated all the code from AuthHandler, and we need for now conference.js to trigger
- // the dialog to pass all required parameters to WaitForOwnerDialog
- // keep it commented, so we do not trigger sending iqs to jicofo twice
- // and showing the broken dialog with no handler
- // store.dispatch(waitForOwner());
- } else {
- store.dispatch(stopWaitForOwner());
- }
- break;
- }
-
- case CONFERENCE_JOINED:
- store.dispatch(stopWaitForOwner());
- store.dispatch(hideLoginDialog());
- break;
-
- case CONFERENCE_LEFT:
- store.dispatch(stopWaitForOwner());
- break;
-
- case CONNECTION_ESTABLISHED:
- store.dispatch(hideLoginDialog());
- break;
-
- case STOP_WAIT_FOR_OWNER:
- _clearExistingWaitForOwnerTimeout(store);
- store.dispatch(hideDialog(WaitForOwnerDialog));
- break;
-
- case UPGRADE_ROLE_FINISHED: {
- const { error, progress } = action;
-
- if (!error && progress === 1) {
- store.dispatch(hideLoginDialog());
- }
- break;
- }
-
- case WAIT_FOR_OWNER: {
- _clearExistingWaitForOwnerTimeout(store);
-
- const { handler, timeoutMs }: { handler: () => void; timeoutMs: number; } = action;
-
- action.waitForOwnerTimeoutID = setTimeout(handler, timeoutMs);
-
- isDialogOpen(store, LoginDialog)
- || store.dispatch(openWaitForOwnerDialog());
- break;
- }
- }
-
- return next(action);
-});
-
-/**
- * Will clear the wait for conference owner timeout handler if any is currently
- * set.
- *
- * @param {Object} store - The redux store.
- * @returns {void}
- */
-function _clearExistingWaitForOwnerTimeout(
- { getState }: IStore) {
- const { waitForOwnerTimeoutID } = getState()['features/authentication'];
-
- waitForOwnerTimeoutID && clearTimeout(waitForOwnerTimeoutID);
-}
-
-/**
- * Checks if the cyclic "wait for conference owner" task is currently scheduled.
- *
- * @param {Object} store - The redux store.
- * @returns {void}
- */
-function _isWaitingForOwner({ getState }: IStore) {
- return getState()['features/authentication'].waitForOwnerTimeoutID;
-}
diff --git a/react/features/base/conference/actionTypes.ts b/react/features/base/conference/actionTypes.ts
index 7647d2ce4f..c7a89b8f0a 100644
--- a/react/features/base/conference/actionTypes.ts
+++ b/react/features/base/conference/actionTypes.ts
@@ -106,6 +106,15 @@ export const CONFERENCE_UNIQUE_ID_SET = 'CONFERENCE_UNIQUE_ID_SET';
*/
export const E2E_RTT_CHANGED = 'E2E_RTT_CHANGED'
+/**
+ * The type of (redux) action which signals that a conference will be initialized.
+ *
+ * {
+ * type: CONFERENCE_WILL_INIT
+ * }
+ */
+export const CONFERENCE_WILL_INIT = 'CONFERENCE_WILL_INIT';
+
/**
* The type of (redux) action which signals that a specific conference will be
* joined.
diff --git a/react/features/base/conference/actions.ts b/react/features/base/conference/actions.ts
index cbda807411..c49465ffb6 100644
--- a/react/features/base/conference/actions.ts
+++ b/react/features/base/conference/actions.ts
@@ -1,11 +1,10 @@
import { createStartMutedConfigurationEvent } from '../../analytics/AnalyticsEvents';
import { sendAnalytics } from '../../analytics/functions';
-import { appNavigate } from '../../app/actions';
import { IReduxState, IStore } from '../../app/types';
import { endpointMessageReceived } from '../../subtitles/actions.any';
import { iAmVisitor } from '../../visitors/functions';
import { getReplaceParticipant } from '../config/functions';
-import { disconnect } from '../connection/actions';
+import { hangup } from '../connection/actions';
import { JITSI_CONNECTION_CONFERENCE_KEY } from '../connection/constants';
import { JitsiConferenceEvents, JitsiE2ePingEvents } from '../lib-jitsi-meet';
import { setAudioMuted, setAudioUnmutePermissions, setVideoMuted, setVideoUnmutePermissions } from '../media/actions';
@@ -41,6 +40,7 @@ import {
CONFERENCE_SUBJECT_CHANGED,
CONFERENCE_TIMESTAMP_CHANGED,
CONFERENCE_UNIQUE_ID_SET,
+ CONFERENCE_WILL_INIT,
CONFERENCE_WILL_JOIN,
CONFERENCE_WILL_LEAVE,
DATA_CHANNEL_CLOSED,
@@ -463,6 +463,19 @@ export function _conferenceWillJoin(conference: IJitsiConference) {
};
}
+/**
+ * Signals the intention of the application to have a conference initialized.
+ *
+ * @returns {{
+ * type: CONFERENCE_WILL_INIT
+ * }}
+ */
+export function conferenceWillInit() {
+ return {
+ type: CONFERENCE_WILL_INIT
+ };
+}
+
/**
* Signals the intention of the application to have the local participant
* join the specified conference.
@@ -647,18 +660,9 @@ export function kickedOut(conference: IJitsiConference, participant: Object) {
* @returns {Function}
*/
export function leaveConference() {
- return async (dispatch: IStore['dispatch']) => {
-
- // FIXME: these should be unified.
- if (navigator.product === 'ReactNative') {
- dispatch(appNavigate(undefined));
- } else {
- dispatch(disconnect(true));
- }
- };
+ return async (dispatch: IStore['dispatch']) => dispatch(hangup(true));
}
-
/**
* Signals that the lock state of a specific JitsiConference changed.
*
diff --git a/react/features/base/conference/middleware.any.ts b/react/features/base/conference/middleware.any.ts
index a70f43017f..b2f25c38be 100644
--- a/react/features/base/conference/middleware.any.ts
+++ b/react/features/base/conference/middleware.any.ts
@@ -49,6 +49,7 @@ import {
} from './actionTypes';
import {
conferenceFailed,
+ conferenceWillInit,
conferenceWillLeave,
createConference,
leaveConference,
@@ -144,12 +145,6 @@ MiddlewareRegistry.register(store => next => action => {
function _conferenceFailed({ dispatch, getState }: IStore, next: Function, action: AnyAction) {
const { conference, error } = action;
- if (error.name === JitsiConferenceErrors.REDIRECTED) {
- if (typeof error.recoverable === 'undefined') {
- error.recoverable = true;
- }
- }
-
const result = next(action);
const { enableForcedReload } = getState()['features/base/config'];
@@ -197,18 +192,22 @@ function _conferenceFailed({ dispatch, getState }: IStore, next: Function, actio
break;
}
case JitsiConferenceErrors.CONFERENCE_MAX_USERS: {
- if (typeof APP === 'undefined') {
- // in case of max users(it can be from a visitor node), let's restore
- // oldConfig if any as we will be back to the main prosody
- const newConfig = restoreConferenceOptions(getState);
-
- if (newConfig) {
- dispatch(overwriteConfig(newConfig)) // @ts-ignore
- .then(dispatch(conferenceWillLeave(conference)))
- .then(conference.leave())
- .then(dispatch(disconnect()))
- .then(dispatch(connect()));
- }
+ dispatch(showErrorNotification({
+ hideErrorSupportLink: true,
+ descriptionKey: 'dialog.maxUsersLimitReached',
+ titleKey: 'dialog.maxUsersLimitReachedTitle'
+ }, NOTIFICATION_TIMEOUT_TYPE.LONG));
+
+ // In case of max users(it can be from a visitor node), let's restore
+ // oldConfig if any as we will be back to the main prosody.
+ const newConfig = restoreConferenceOptions(getState);
+
+ if (newConfig) {
+ dispatch(overwriteConfig(newConfig)) // @ts-ignore
+ .then(dispatch(conferenceWillLeave(conference)))
+ .then(conference.leave())
+ .then(dispatch(disconnect()))
+ .then(dispatch(connect()));
}
break;
@@ -216,45 +215,44 @@ function _conferenceFailed({ dispatch, getState }: IStore, next: Function, actio
case JitsiConferenceErrors.OFFER_ANSWER_FAILED:
sendAnalytics(createOfferAnswerFailedEvent());
break;
+
case JitsiConferenceErrors.REDIRECTED: {
- // once conference.js is gone this can be removed and both
- // redirect logics to be merged
- if (typeof APP === 'undefined') {
- const newConfig = getVisitorOptions(getState, error.params);
-
- if (!newConfig) {
- logger.warn('Not redirected missing params');
- break;
- }
+ const newConfig = getVisitorOptions(getState, error.params);
- const [ vnode ] = error.params;
+ if (!newConfig) {
+ logger.warn('Not redirected missing params');
+ break;
+ }
- dispatch(overwriteConfig(newConfig)) // @ts-ignore
- .then(dispatch(conferenceWillLeave(conference)))
- .then(conference.leave())
- .then(dispatch(disconnect()))
- .then(dispatch(setIAmVisitor(Boolean(vnode))))
+ const [ vnode ] = error.params;
- // we do not clear local tracks on error, so we need to manually clear them
- .then(dispatch(destroyLocalTracks()))
- .then(dispatch(connect()));
- }
+ dispatch(overwriteConfig(newConfig)) // @ts-ignore
+ .then(dispatch(conferenceWillLeave(conference)))
+ .then(dispatch(disconnect()))
+ .then(dispatch(setIAmVisitor(Boolean(vnode))))
+
+ // we do not clear local tracks on error, so we need to manually clear them
+ .then(dispatch(destroyLocalTracks()))
+ .then(() => {
+ dispatch(conferenceWillInit());
+ })
+ .then(dispatch(connect()));
break;
}
}
- if (typeof APP === 'undefined') {
- !error.recoverable
- && conference
- && conference.leave(CONFERENCE_LEAVE_REASONS.UNRECOVERABLE_ERROR).catch((reason: Error) => {
- // Even though we don't care too much about the failure, it may be
- // good to know that it happen, so log it (on the info level).
- logger.info('JitsiConference.leave() rejected with:', reason);
- });
- } else {
- // FIXME: Workaround for the web version. Currently, the creation of the
- // conference is handled by /conference.js and appropriate failure handlers
- // are set there.
+ !error.recoverable
+ && conference
+ && conference.leave(CONFERENCE_LEAVE_REASONS.UNRECOVERABLE_ERROR).catch((reason: Error) => {
+ // Even though we don't care too much about the failure, it may be
+ // good to know that it happen, so log it (on the info level).
+ logger.info('JitsiConference.leave() rejected with:', reason);
+ });
+
+ // FIXME: Workaround for the web version. Currently, the creation of the
+ // conference is handled by /conference.js and appropriate failure handlers
+ // are set there.
+ if (typeof APP !== 'undefined') {
_removeUnloadHandler(getState);
}
@@ -339,12 +337,16 @@ function _conferenceJoined({ dispatch, getState }: IStore, next: Function, actio
* @private
* @returns {Object} The value returned by {@code next(action)}.
*/
-function _connectionEstablished({ dispatch }: IStore, next: Function, action: AnyAction) {
+async function _connectionEstablished({ dispatch }: IStore, next: Function, action: AnyAction) {
const result = next(action);
// FIXME: Workaround for the web version. Currently, the creation of the
// conference is handled by /conference.js.
- typeof APP === 'undefined' && dispatch(createConference());
+ if (typeof APP === 'undefined') {
+ dispatch(createConference());
+
+ return result;
+ }
return result;
}
@@ -386,45 +388,45 @@ function _logJwtErrors(message: string, state: IReduxState) {
function _connectionFailed({ dispatch, getState }: IStore, next: Function, action: AnyAction) {
_logJwtErrors(action.error.message, getState());
+ dispatch(showErrorNotification({
+ descriptionKey: 'dialog.tokenAuthFailed',
+ titleKey: 'dialog.tokenAuthFailedTitle'
+ }, NOTIFICATION_TIMEOUT_TYPE.LONG));
+
const result = next(action);
_removeUnloadHandler(getState);
- // FIXME: Workaround for the web version. Currently, the creation of the
- // conference is handled by /conference.js and appropriate failure handlers
- // are set there.
- if (typeof APP === 'undefined') {
- const { connection } = action;
- const { error } = action;
-
- forEachConference(getState, conference => {
- // It feels that it would make things easier if JitsiConference
- // in lib-jitsi-meet would monitor it's connection and emit
- // CONFERENCE_FAILED when it's dropped. It has more knowledge on
- // whether it can recover or not. But because the reload screen
- // and the retry logic is implemented in the app maybe it can be
- // left this way for now.
- if (conference.getConnection() === connection) {
- // XXX Note that on mobile the error type passed to
- // connectionFailed is always an object with .name property.
- // This fact needs to be checked prior to enabling this logic on
- // web.
- const conferenceAction
- = conferenceFailed(conference, error.name);
-
- // Copy the recoverable flag if set on the CONNECTION_FAILED
- // action to not emit recoverable action caused by
- // a non-recoverable one.
- if (typeof error.recoverable !== 'undefined') {
- conferenceAction.error.recoverable = error.recoverable;
- }
-
- dispatch(conferenceAction);
+ const { connection } = action;
+ const { error } = action;
+
+ forEachConference(getState, conference => {
+ // TODO: revisit this
+ // It feels that it would make things easier if JitsiConference
+ // in lib-jitsi-meet would monitor it's connection and emit
+ // CONFERENCE_FAILED when it's dropped. It has more knowledge on
+ // whether it can recover or not. But because the reload screen
+ // and the retry logic is implemented in the app maybe it can be
+ // left this way for now.
+ if (conference.getConnection() === connection) {
+ // XXX Note that on mobile the error type passed to
+ // connectionFailed is always an object with .name property.
+ // This fact needs to be checked prior to enabling this logic on
+ // web.
+ const conferenceAction = conferenceFailed(conference, error.name);
+
+ // Copy the recoverable flag if set on the CONNECTION_FAILED
+ // action to not emit recoverable action caused by
+ // a non-recoverable one.
+ if (typeof error.recoverable !== 'undefined') {
+ conferenceAction.error.recoverable = error.recoverable;
}
- return true;
- });
- }
+ dispatch(conferenceAction);
+ }
+
+ return true;
+ });
return result;
}
diff --git a/react/features/base/conference/middleware.web.ts b/react/features/base/conference/middleware.web.ts
index 31aaa2cbd4..9863ea361f 100644
--- a/react/features/base/conference/middleware.web.ts
+++ b/react/features/base/conference/middleware.web.ts
@@ -9,7 +9,8 @@ import {
CONFERENCE_FAILED,
CONFERENCE_JOINED,
CONFERENCE_JOIN_IN_PROGRESS,
- CONFERENCE_LEFT, KICKED_OUT
+ CONFERENCE_LEFT,
+ KICKED_OUT
} from './actionTypes';
import logger from './logger';
import './middleware.any';
diff --git a/react/features/base/conference/reducer.ts b/react/features/base/conference/reducer.ts
index 86d0bbe189..33b816ffbb 100644
--- a/react/features/base/conference/reducer.ts
+++ b/react/features/base/conference/reducer.ts
@@ -155,6 +155,9 @@ export interface IConferenceState {
export interface IJitsiConferenceRoom {
locked: boolean;
+ moderator: {
+ logout: Function;
+ };
myroomjid: string;
roomjid: string;
}
diff --git a/react/features/base/connection/actions.any.ts b/react/features/base/connection/actions.any.ts
index 627aa40010..0d14747a9e 100644
--- a/react/features/base/connection/actions.any.ts
+++ b/react/features/base/connection/actions.any.ts
@@ -1,6 +1,10 @@
import _ from 'lodash';
-import { IReduxState } from '../../app/types';
+import { IReduxState, IStore } from '../../app/types';
+import { setPrejoinDisplayNameRequired } from '../../prejoin/actions.any';
+import { conferenceLeft, conferenceWillLeave } from '../conference/actions';
+import { getCurrentConference } from '../conference/functions';
+import JitsiMeetJS, { JitsiConnectionEvents } from '../lib-jitsi-meet';
import {
appendURLParam,
getBackendSafeRoomName
@@ -10,8 +14,10 @@ import {
CONNECTION_DISCONNECTED,
CONNECTION_ESTABLISHED,
CONNECTION_FAILED,
+ CONNECTION_WILL_CONNECT,
SET_LOCATION_URL
} from './actionTypes';
+import { JITSI_CONNECTION_URL_KEY } from './constants';
import logger from './logger';
/**
@@ -194,3 +200,194 @@ export function setLocationURL(locationURL?: URL) {
locationURL
};
}
+
+/**
+ * Opens new connection.
+ *
+ * @param {string} [id] - The XMPP user's ID (e.g. {@code [email protected]}).
+ * @param {string} [password] - The XMPP user's password.
+ * @returns {Function}
+ */
+export function _connectInternal(id?: string, password?: string) {
+ return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
+ const state = getState();
+ const options = constructOptions(state);
+ const { locationURL } = state['features/base/connection'];
+ const { jwt } = state['features/base/jwt'];
+
+ const connection = new JitsiMeetJS.JitsiConnection(options.appId, jwt, options);
+
+ connection[JITSI_CONNECTION_URL_KEY] = locationURL;
+
+ dispatch(_connectionWillConnect(connection));
+
+ return new Promise((resolve, reject) => {
+ connection.addEventListener(
+ JitsiConnectionEvents.CONNECTION_DISCONNECTED,
+ _onConnectionDisconnected);
+ connection.addEventListener(
+ JitsiConnectionEvents.CONNECTION_ESTABLISHED,
+ _onConnectionEstablished);
+ connection.addEventListener(
+ JitsiConnectionEvents.CONNECTION_FAILED,
+ _onConnectionFailed);
+
+ /**
+ * Marks the display name for the prejoin screen as required.
+ * This can happen if a user tries to join a room with lobby enabled.
+ */
+ connection.addEventListener(
+ JitsiConnectionEvents.DISPLAY_NAME_REQUIRED,
+ () => dispatch(setPrejoinDisplayNameRequired())
+ );
+
+ /**
+ * Unsubscribe the connection instance from
+ * {@code CONNECTION_DISCONNECTED} and {@code CONNECTION_FAILED} events.
+ *
+ * @returns {void}
+ */
+ function unsubscribe() {
+ connection.removeEventListener(
+ JitsiConnectionEvents.CONNECTION_DISCONNECTED, _onConnectionDisconnected);
+ connection.removeEventListener(JitsiConnectionEvents.CONNECTION_FAILED, _onConnectionFailed);
+ }
+
+ /**
+ * Dispatches {@code CONNECTION_DISCONNECTED} action when connection is
+ * disconnected.
+ *
+ * @private
+ * @returns {void}
+ */
+ function _onConnectionDisconnected() {
+ unsubscribe();
+ dispatch(connectionDisconnected(connection));
+ resolve(connection);
+ }
+
+ /**
+ * Rejects external promise when connection fails.
+ *
+ * @param {JitsiConnectionErrors} err - Connection error.
+ * @param {string} [message] - Error message supplied by lib-jitsi-meet.
+ * @param {Object} [credentials] - The invalid credentials that were
+ * used to authenticate and the authentication failed.
+ * @param {string} [credentials.jid] - The XMPP user's ID.
+ * @param {string} [credentials.password] - The XMPP user's password.
+ * @param {Object} details - Additional information about the error.
+ * @private
+ * @returns {void}
+ */
+ function _onConnectionFailed( // eslint-disable-line max-params
+ err: string,
+ message: string,
+ credentials: any,
+ details: Object) {
+ unsubscribe();
+
+ dispatch(connectionFailed(connection, {
+ credentials,
+ details,
+ name: err,
+ message
+ }));
+
+ reject(err);
+ }
+
+ /**
+ * Resolves external promise when connection is established.
+ *
+ * @private
+ * @returns {void}
+ */
+ function _onConnectionEstablished() {
+ connection.removeEventListener(JitsiConnectionEvents.CONNECTION_ESTABLISHED, _onConnectionEstablished);
+ dispatch(connectionEstablished(connection, Date.now()));
+ resolve(connection);
+ }
+
+ connection.connect({
+ id,
+ password
+ });
+ });
+ };
+}
+
+/**
+ * Create an action for when a connection will connect.
+ *
+ * @param {JitsiConnection} connection - The {@code JitsiConnection} which will
+ * connect.
+ * @private
+ * @returns {{
+ * type: CONNECTION_WILL_CONNECT,
+ * connection: JitsiConnection
+ * }}
+ */
+function _connectionWillConnect(connection: Object) {
+ return {
+ type: CONNECTION_WILL_CONNECT,
+ connection
+ };
+}
+
+/**
+ * Closes connection.
+ *
+ * @returns {Function}
+ */
+export function disconnect() {
+ return (dispatch: IStore['dispatch'], getState: IStore['getState']): Promise<void> => {
+ const state = getState();
+
+ // The conference we have already joined or are joining.
+ const conference_ = getCurrentConference(state);
+
+ // Promise which completes when the conference has been left and the
+ // connection has been disconnected.
+ let promise;
+
+ // Leave the conference.
+ if (conference_) {
+ // In a fashion similar to JitsiConference's CONFERENCE_LEFT event
+ // (and the respective Redux action) which is fired after the
+ // conference has been left, notify the application about the
+ // intention to leave the conference.
+ dispatch(conferenceWillLeave(conference_));
+
+ promise
+ = conference_.leave()
+ .catch((error: Error) => {
+ logger.warn(
+ 'JitsiConference.leave() rejected with:',
+ error);
+
+ // The library lib-jitsi-meet failed to make the
+ // JitsiConference leave. Which may be because
+ // JitsiConference thinks it has already left.
+ // Regardless of the failure reason, continue in
+ // jitsi-meet as if the leave has succeeded.
+ dispatch(conferenceLeft(conference_));
+ });
+ } else {
+ promise = Promise.resolve();
+ }
+
+ // Disconnect the connection.
+ const { connecting, connection } = state['features/base/connection'];
+
+ // The connection we have already connected or are connecting.
+ const connection_ = connection || connecting;
+
+ if (connection_) {
+ promise = promise.then(() => connection_.disconnect());
+ } else {
+ logger.info('No connection found while disconnecting.');
+ }
+
+ return promise;
+ };
+}
diff --git a/react/features/base/connection/actions.native.ts b/react/features/base/connection/actions.native.ts
index 0b2193dd8e..e11a3a458f 100644
--- a/react/features/base/connection/actions.native.ts
+++ b/react/features/base/connection/actions.native.ts
@@ -1,19 +1,7 @@
+import { appNavigate } from '../../app/actions.native';
import { IStore } from '../../app/types';
-import { conferenceLeft, conferenceWillLeave } from '../conference/actions';
-import { getCurrentConference } from '../conference/functions';
-import JitsiMeetJS, { JitsiConnectionEvents } from '../lib-jitsi-meet';
-import {
- CONNECTION_WILL_CONNECT
-} from './actionTypes';
-import {
- connectionDisconnected,
- connectionEstablished,
- connectionFailed,
- constructOptions
-} from './actions.any';
-import { JITSI_CONNECTION_URL_KEY } from './constants';
-import logger from './logger';
+import { _connectInternal } from './actions.any';
export * from './actions.any';
@@ -25,178 +13,16 @@ export * from './actions.any';
* @returns {Function}
*/
export function connect(id?: string, password?: string) {
- return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
- const state = getState();
- const options = constructOptions(state);
- const { locationURL } = state['features/base/connection'];
- const { jwt } = state['features/base/jwt'];
- const connection = new JitsiMeetJS.JitsiConnection(options.appId, jwt, options);
-
- connection[JITSI_CONNECTION_URL_KEY] = locationURL;
-
- dispatch(_connectionWillConnect(connection));
-
- connection.addEventListener(
- JitsiConnectionEvents.CONNECTION_DISCONNECTED,
- _onConnectionDisconnected);
- connection.addEventListener(
- JitsiConnectionEvents.CONNECTION_ESTABLISHED,
- _onConnectionEstablished);
- connection.addEventListener(
- JitsiConnectionEvents.CONNECTION_FAILED,
- _onConnectionFailed);
-
- connection.connect({
- id,
- password
- });
-
- /**
- * Dispatches {@code CONNECTION_DISCONNECTED} action when connection is
- * disconnected.
- *
- * @private
- * @returns {void}
- */
- function _onConnectionDisconnected() {
- unsubscribe();
- dispatch(connectionDisconnected(connection));
- }
-
- /**
- * Resolves external promise when connection is established.
- *
- * @private
- * @returns {void}
- */
- function _onConnectionEstablished() {
- connection.removeEventListener(
- JitsiConnectionEvents.CONNECTION_ESTABLISHED,
- _onConnectionEstablished);
- dispatch(connectionEstablished(connection, Date.now()));
- }
-
- /**
- * Rejects external promise when connection fails.
- *
- * @param {JitsiConnectionErrors} err - Connection error.
- * @param {string} [msg] - Error message supplied by lib-jitsi-meet.
- * @param {Object} [credentials] - The invalid credentials that were
- * used to authenticate and the authentication failed.
- * @param {string} [credentials.jid] - The XMPP user's ID.
- * @param {string} [credentials.password] - The XMPP user's password.
- * @param {Object} details - Additional information about the error.
- * @private
- * @returns {void}
- */
- function _onConnectionFailed( // eslint-disable-line max-params
- err: string,
- msg: string,
- credentials: any,
- details: Object) {
- unsubscribe();
- dispatch(
- connectionFailed(
- connection, {
- credentials,
- details,
- name: err,
- message: msg
- }
- ));
- }
-
- /**
- * Unsubscribe the connection instance from
- * {@code CONNECTION_DISCONNECTED} and {@code CONNECTION_FAILED} events.
- *
- * @returns {void}
- */
- function unsubscribe() {
- connection.removeEventListener(
- JitsiConnectionEvents.CONNECTION_DISCONNECTED,
- _onConnectionDisconnected);
- connection.removeEventListener(
- JitsiConnectionEvents.CONNECTION_FAILED,
- _onConnectionFailed);
- }
- };
-}
-
-/**
- * Create an action for when a connection will connect.
- *
- * @param {JitsiConnection} connection - The {@code JitsiConnection} which will
- * connect.
- * @private
- * @returns {{
- * type: CONNECTION_WILL_CONNECT,
- * connection: JitsiConnection
- * }}
- */
-function _connectionWillConnect(connection: Object) {
- return {
- type: CONNECTION_WILL_CONNECT,
- connection
- };
+ return (dispatch: IStore['dispatch']) => dispatch(_connectInternal(id, password));
}
/**
- * Closes connection.
+ * Hangup.
*
- * @param {boolean} _ - Used in web.
+ * @param {boolean} [_requestFeedback] - Whether to attempt showing a
+ * request for call feedback.
* @returns {Function}
*/
-export function disconnect(_?: boolean) {
- /* eslint-enable @typescript-eslint/no-unused-vars */
- return (dispatch: IStore['dispatch'], getState: IStore['getState']): Promise<void> => {
- const state = getState();
-
- // The conference we have already joined or are joining.
- const conference_ = getCurrentConference(state);
-
- // Promise which completes when the conference has been left and the
- // connection has been disconnected.
- let promise;
-
- // Leave the conference.
- if (conference_) {
- // In a fashion similar to JitsiConference's CONFERENCE_LEFT event
- // (and the respective Redux action) which is fired after the
- // conference has been left, notify the application about the
- // intention to leave the conference.
- dispatch(conferenceWillLeave(conference_));
-
- promise
- = conference_.leave()
- .catch((error: Error) => {
- logger.warn(
- 'JitsiConference.leave() rejected with:',
- error);
-
- // The library lib-jitsi-meet failed to make the
- // JitsiConference leave. Which may be because
- // JitsiConference thinks it has already left.
- // Regardless of the failure reason, continue in
- // jitsi-meet as if the leave has succeeded.
- dispatch(conferenceLeft(conference_));
- });
- } else {
- promise = Promise.resolve();
- }
-
- // Disconnect the connection.
- const { connecting, connection } = state['features/base/connection'];
-
- // The connection we have already connected or are connecting.
- const connection_ = connection || connecting;
-
- if (connection_) {
- promise = promise.then(() => connection_.disconnect());
- } else {
- logger.info('No connection found while disconnecting.');
- }
-
- return promise;
- };
+export function hangup(_requestFeedback = false) {
+ return (dispatch: IStore['dispatch']) => dispatch(appNavigate(undefined));
}
diff --git a/react/features/base/connection/actions.web.ts b/react/features/base/connection/actions.web.ts
index b4f1a84d9d..0c00eca969 100644
--- a/react/features/base/connection/actions.web.ts
+++ b/react/features/base/connection/actions.web.ts
@@ -1,52 +1,67 @@
+// @ts-expect-error
+import { jitsiLocalStorage } from '@jitsi/js-utils';
+
import { IStore } from '../../app/types';
+import { getCustomerDetails } from '../../jaas/actions.any';
+import { getJaasJWT, isVpaasMeeting } from '../../jaas/functions';
import { showWarningNotification } from '../../notifications/actions';
import { NOTIFICATION_TIMEOUT_TYPE } from '../../notifications/constants';
import { stopLocalVideoRecording } from '../../recording/actions.any';
import LocalRecordingManager from '../../recording/components/Recording/LocalRecordingManager.web';
-import { configureInitialDevices } from '../devices/actions';
-import { getBackendSafeRoomName } from '../util/uri';
+import { setJWT } from '../jwt/actions';
-export {
- connectionDisconnected,
- connectionEstablished,
- connectionFailed,
- setLocationURL
-} from './actions.any';
-import logger from './logger';
+import { _connectInternal } from './actions.any';
export * from './actions.any';
/**
* Opens new connection.
*
- * @returns {Promise<JitsiConnection>}
+ * @param {string} [id] - The XMPP user's ID (e.g. {@code [email protected]}).
+ * @param {string} [password] - The XMPP user's password.
+ * @returns {Function}
*/
-export function connect() {
+export function connect(id?: string, password?: string) {
return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
- const room = getBackendSafeRoomName(getState()['features/base/conference'].room);
+ const state = getState();
+ const { jwt } = state['features/base/jwt'];
+ const { iAmRecorder, iAmSipGateway } = state['features/base/config'];
+
+ if (!iAmRecorder && !iAmSipGateway && isVpaasMeeting(state)) {
+ return dispatch(getCustomerDetails())
+ .then(() => {
+ if (!jwt) {
+ return getJaasJWT(state);
+ }
+ })
+ .then(j => j && dispatch(setJWT(j)))
+ .then(() => _connectInternal(id, password));
+ }
+
+ // used by jibri
+ const usernameOverride = jitsiLocalStorage.getItem('xmpp_username_override');
+ const passwordOverride = jitsiLocalStorage.getItem('xmpp_password_override');
+
+ if (usernameOverride && usernameOverride.length > 0) {
+ id = usernameOverride; // eslint-disable-line no-param-reassign
+ }
+ if (passwordOverride && passwordOverride.length > 0) {
+ password = passwordOverride; // eslint-disable-line no-param-reassign
+ }
- // XXX For web based version we use conference initialization logic
- // from the old app (at the moment of writing).
- return dispatch(configureInitialDevices()).then(
- () => APP.conference.init({
- roomName: room
- }).catch((error: Error) => {
- APP.API.notifyConferenceLeft(APP.conference.roomName);
- logger.error(error);
- }));
+ return dispatch(_connectInternal(id, password));
};
}
/**
* Closes connection.
*
- * @param {boolean} [requestFeedback] - Whether or not to attempt showing a
+ * @param {boolean} [requestFeedback] - Whether to attempt showing a
* request for call feedback.
* @returns {Function}
*/
-export function disconnect(requestFeedback = false) {
- // XXX For web based version we use conference hanging up logic from the old
- // app.
+export function hangup(requestFeedback = false) {
+ // XXX For web based version we use conference hanging up logic from the old app.
return async (dispatch: IStore['dispatch']) => {
if (LocalRecordingManager.isRecordingLocally()) {
dispatch(stopLocalVideoRecording());
diff --git a/react/features/base/connection/middleware.web.ts b/react/features/base/connection/middleware.web.ts
new file mode 100644
index 0000000000..be32286404
--- /dev/null
+++ b/react/features/base/connection/middleware.web.ts
@@ -0,0 +1,30 @@
+import MiddlewareRegistry from '../redux/MiddlewareRegistry';
+
+import { CONNECTION_WILL_CONNECT } from './actionTypes';
+
+/**
+ * The feature announced so we can distinguish jibri participants.
+ *
+ * @type {string}
+ */
+export const DISCO_JIBRI_FEATURE = 'http://jitsi.org/protocol/jibri';
+
+MiddlewareRegistry.register(({ getState }) => next => action => {
+ switch (action.type) {
+ case CONNECTION_WILL_CONNECT: {
+ const { connection } = action;
+ const { iAmRecorder } = getState()['features/base/config'];
+
+ if (iAmRecorder) {
+ connection.addFeature(DISCO_JIBRI_FEATURE);
+ }
+
+ // @ts-ignore
+ APP.connection = connection;
+
+ break;
+ }
+ }
+
+ return next(action);
+});
diff --git a/react/features/base/tracks/actions.any.ts b/react/features/base/tracks/actions.any.ts
index 7a9c7679e7..0151baf0e7 100644
--- a/react/features/base/tracks/actions.any.ts
+++ b/react/features/base/tracks/actions.any.ts
@@ -142,7 +142,7 @@ export function createLocalTracksA(options: ITrackOptions = {}) {
const promises = [];
// The following executes on React Native only at the time of this
- // writing. The effort to port Web's createInitialLocalTracksAndConnect
+ // writing. The effort to port Web's createInitialLocalTracks
// is significant and that's where the function createLocalTracksF got
// born. I started with the idea a porting so that we could inherit the
// ability to getUserMedia for audio only or video only if getUserMedia
diff --git a/react/features/conference/actions.web.ts b/react/features/conference/actions.web.ts
index f01c89a6c0..c1f3273f99 100644
--- a/react/features/conference/actions.web.ts
+++ b/react/features/conference/actions.web.ts
@@ -1,9 +1,12 @@
import { IStore } from '../app/types';
+import { configureInitialDevices } from '../base/devices/actions.web';
import { getParticipantDisplayName } from '../base/participants/functions';
+import { getBackendSafeRoomName } from '../base/util/uri';
import { showNotification } from '../notifications/actions';
import { NOTIFICATION_TIMEOUT_TYPE, NOTIFICATION_TYPE } from '../notifications/constants';
import { DISMISS_CALENDAR_NOTIFICATION } from './actionTypes';
+import logger from './logger';
/**
* Notify that we've been kicked out of the conference.
@@ -45,3 +48,24 @@ export function dismissCalendarNotification() {
type: DISMISS_CALENDAR_NOTIFICATION
};
}
+
+/**
+ * Init.
+ *
+ * @returns {Promise<JitsiConnection>}
+ */
+export function init() {
+ return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
+ const room = getBackendSafeRoomName(getState()['features/base/conference'].room);
+
+ // XXX For web based version we use conference initialization logic
+ // from the old app (at the moment of writing).
+ return dispatch(configureInitialDevices()).then(
+ () => APP.conference.init({
+ roomName: room
+ }).catch((error: Error) => {
+ APP.API.notifyConferenceLeft(APP.conference.roomName);
+ logger.error(error);
+ }));
+ };
+}
diff --git a/react/features/conference/components/web/Conference.tsx b/react/features/conference/components/web/Conference.tsx
index 7a1dfde48a..0aff233520 100644
--- a/react/features/conference/components/web/Conference.tsx
+++ b/react/features/conference/components/web/Conference.tsx
@@ -7,7 +7,7 @@ import { connect as reactReduxConnect } from 'react-redux';
import VideoLayout from '../../../../../modules/UI/videolayout/VideoLayout';
import { IReduxState, IStore } from '../../../app/types';
import { getConferenceNameForTitle } from '../../../base/conference/functions';
-import { connect, disconnect } from '../../../base/connection/actions.web';
+import { hangup } from '../../../base/connection/actions.web';
import { isMobileBrowser } from '../../../base/environment/utils';
import { translate } from '../../../base/i18n/functions';
import { setColorAlpha } from '../../../base/util/helpers';
@@ -29,6 +29,7 @@ import JitsiPortal from '../../../toolbox/components/web/JitsiPortal';
import Toolbox from '../../../toolbox/components/web/Toolbox';
import { LAYOUT_CLASSNAMES } from '../../../video-layout/constants';
import { getCurrentLayout } from '../../../video-layout/functions.any';
+import { init } from '../../actions.web';
import { maybeShowSuboptimalExperienceNotification } from '../../functions.web';
import {
AbstractConference,
@@ -187,7 +188,7 @@ class Conference extends AbstractConference<IProps, any> {
FULL_SCREEN_EVENTS.forEach(name =>
document.removeEventListener(name, this._onFullScreenChange));
- APP.conference.isJoined() && this.props.dispatch(disconnect());
+ APP.conference.isJoined() && this.props.dispatch(hangup());
}
/**
@@ -374,7 +375,7 @@ class Conference extends AbstractConference<IProps, any> {
const { dispatch, t } = this.props;
- dispatch(connect());
+ dispatch(init());
maybeShowSuboptimalExperienceNotification(dispatch, t);
}
diff --git a/react/features/prejoin/actions.any.ts b/react/features/prejoin/actions.any.ts
new file mode 100644
index 0000000000..393553c3ee
--- /dev/null
+++ b/react/features/prejoin/actions.any.ts
@@ -0,0 +1,14 @@
+import {
+ SET_PREJOIN_DISPLAY_NAME_REQUIRED
+} from './actionTypes';
+
+/**
+ * Action used to set the stance of the display name.
+ *
+ * @returns {Object}
+ */
+export function setPrejoinDisplayNameRequired() {
+ return {
+ type: SET_PREJOIN_DISPLAY_NAME_REQUIRED
+ };
+}
diff --git a/react/features/prejoin/actions.web.ts b/react/features/prejoin/actions.web.ts
index b7f92227f7..2016994100 100644
--- a/react/features/prejoin/actions.web.ts
+++ b/react/features/prejoin/actions.web.ts
@@ -3,6 +3,7 @@ import { v4 as uuidv4 } from 'uuid';
import { IStore } from '../app/types';
import { updateConfig } from '../base/config/actions';
import { getDialOutStatusUrl, getDialOutUrl } from '../base/config/functions';
+import { connect } from '../base/connection/actions';
import { browser } from '../base/lib-jitsi-meet';
import { createLocalTrack } from '../base/lib-jitsi-meet/functions';
import { MEDIA_TYPE } from '../base/media/constants';
@@ -31,7 +32,6 @@ import {
SET_JOIN_BY_PHONE_DIALOG_VISIBLITY,
SET_PRECALL_TEST_RESULTS,
SET_PREJOIN_DEVICE_ERRORS,
- SET_PREJOIN_DISPLAY_NAME_REQUIRED,
SET_PREJOIN_PAGE_VISIBILITY,
SET_SKIP_PREJOIN_RELOAD
} from './actionTypes';
@@ -66,6 +66,8 @@ const STATUS_REQ_FREQUENCY = 2000;
*/
const STATUS_REQ_CAP = 45;
+export * from './actions.any';
+
/**
* Polls for status change after dial out.
* Changes dialog message based on response, closes the dialog if there is an error,
@@ -226,33 +228,37 @@ export function joinConference(options?: Object, ignoreJoiningInProgress = false
dispatch(setJoiningInProgress(true));
}
- const state = getState();
- let localTracks = getLocalTracks(state['features/base/tracks']);
-
options && dispatch(updateConfig(options));
- // Do not signal audio/video tracks if the user joins muted.
- for (const track of localTracks) {
- // Always add the audio track on Safari because of a known issue where audio playout doesn't happen
- // if the user joins audio and video muted.
- if (track.muted
- && !(browser.isWebKitBased() && track.jitsiTrack && track.jitsiTrack.getType() === MEDIA_TYPE.AUDIO)) {
- try {
- await dispatch(replaceLocalTrack(track.jitsiTrack, null));
- } catch (error) {
- logger.error(`Failed to replace local track (${track.jitsiTrack}) with null: ${error}`);
+ dispatch(connect()).then(async () => {
+ // TODO keep this here till we move tracks and conference management from
+ // conference.js to react.
+ const state = getState();
+ let localTracks = getLocalTracks(state['features/base/tracks']);
+
+ // Do not signal audio/video tracks if the user joins muted.
+ for (const track of localTracks) {
+ // Always add the audio track on Safari because of a known issue where audio playout doesn't happen
+ // if the user joins audio and video muted.
+ if (track.muted && !(browser.isWebKitBased() && track.jitsiTrack
+ && track.jitsiTrack.getType() === MEDIA_TYPE.AUDIO)) {
+ try {
+ await dispatch(replaceLocalTrack(track.jitsiTrack, null));
+ } catch (error) {
+ logger.error(`Failed to replace local track (${track.jitsiTrack}) with null: ${error}`);
+ }
}
}
- }
- // Re-fetch the local tracks after muted tracks have been removed above.
- // This is needed, because the tracks are effectively disposed by the replaceLocalTrack and should not be used
- // anymore.
- localTracks = getLocalTracks(getState()['features/base/tracks']);
+ // Re-fetch the local tracks after muted tracks have been removed above.
+ // This is needed, because the tracks are effectively disposed by the replaceLocalTrack and should not be
+ // used anymore.
+ localTracks = getLocalTracks(getState()['features/base/tracks']);
- const jitsiTracks = localTracks.map((t: any) => t.jitsiTrack);
+ const jitsiTracks = localTracks.map((t: any) => t.jitsiTrack);
- APP.conference.prejoinStart(jitsiTracks);
+ APP.conference.startConference(jitsiTracks).catch(logger.error);
+ });
};
}
@@ -465,17 +471,6 @@ export function setDialOutCountry(value: Object) {
};
}
-/**
- * Action used to set the stance of the display name.
- *
- * @returns {Object}
- */
-export function setPrejoinDisplayNameRequired() {
- return {
- type: SET_PREJOIN_DISPLAY_NAME_REQUIRED
- };
-}
-
/**
* Action used to set the dial out number.
*
diff --git a/react/features/room-lock/middleware.ts b/react/features/room-lock/middleware.ts
index 9ba611c0fd..b83c813777 100644
--- a/react/features/room-lock/middleware.ts
+++ b/react/features/room-lock/middleware.ts
@@ -12,7 +12,7 @@ import {
import { hideDialog } from '../base/dialog/actions';
import { JitsiConferenceErrors } from '../base/lib-jitsi-meet';
import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';
-import { showNotification } from '../notifications/actions';
+import { showErrorNotification, showNotification } from '../notifications/actions';
import { NOTIFICATION_TIMEOUT_TYPE } from '../notifications/constants';
import { _openPasswordRequiredPrompt } from './actions';
@@ -147,10 +147,10 @@ function _setPasswordFailed(store: IStore, next: Function, action: AnyAction) {
descriptionKey = 'dialog.lockMessage';
titleKey = 'dialog.lockTitle';
}
- APP.UI.messageHandler.showError({
+ APP.store.dispatch(showErrorNotification({
descriptionKey,
titleKey
- });
+ }, NOTIFICATION_TIMEOUT_TYPE.LONG));
}
return next(action);
diff --git a/react/features/settings/actions.native.ts b/react/features/settings/actions.native.ts
new file mode 100644
index 0000000000..532c5d437d
--- /dev/null
+++ b/react/features/settings/actions.native.ts
@@ -0,0 +1,10 @@
+/**
+ * Opens {@code LogoutDialog}.
+ *
+ * @param {Function} _onLogout - The event in {@code LogoutDialog} that should be
+ * enabled on click.
+ * @returns {Function}
+ */
+export function openLogoutDialog(_onLogout: Function): any {
+ // this is available only for web at the moment
+}
diff --git a/react/features/settings/components/web/ProfileTab.tsx b/react/features/settings/components/web/ProfileTab.tsx
index 13b68fbffe..e35862dd0d 100644
--- a/react/features/settings/components/web/ProfileTab.tsx
+++ b/react/features/settings/components/web/ProfileTab.tsx
@@ -2,11 +2,12 @@ import { Theme } from '@mui/material';
import { withStyles } from '@mui/styles';
import React from 'react';
import { WithTranslation } from 'react-i18next';
+import { connect } from 'react-redux';
-// @ts-expect-error
-import UIEvents from '../../../../../service/UI/UIEvents';
import { createProfilePanelButtonEvent } from '../../../analytics/AnalyticsEvents';
import { sendAnalytics } from '../../../analytics/functions';
+import { IStore } from '../../../app/types';
+import { login, logout } from '../../../authentication/actions.web';
import Avatar from '../../../base/avatar/components/Avatar';
import AbstractDialogTab, {
IProps as AbstractDialogTabProps } from '../../../base/dialog/components/web/AbstractDialogTab';
@@ -14,7 +15,6 @@ import { translate } from '../../../base/i18n/functions';
import { withPixelLineHeight } from '../../../base/styles/functions.web';
import Button from '../../../base/ui/components/web/Button';
import Input from '../../../base/ui/components/web/Input';
-import { openLogoutDialog } from '../../actions';
/**
* The type of the React {@code Component} props of {@link ProfileTab}.
@@ -22,7 +22,7 @@ import { openLogoutDialog } from '../../actions';
export interface IProps extends AbstractDialogTabProps, WithTranslation {
/**
- * Whether or not server-side authentication is available.
+ * Whether server-side authentication is available.
*/
authEnabled: boolean;
@@ -36,6 +36,11 @@ export interface IProps extends AbstractDialogTabProps, WithTranslation {
*/
classes: any;
+ /**
+ * Invoked to change the configured calendar integration.
+ */
+ dispatch: IStore['dispatch'];
+
/**
* The display name to display for the local participant.
*/
@@ -204,13 +209,11 @@ class ProfileTab extends AbstractDialogTab<IProps, any> {
if (this.props.authLogin) {
sendAnalytics(createProfilePanelButtonEvent('logout.button'));
- APP.store.dispatch(openLogoutDialog(
- () => APP.UI.emitEvent(UIEvents.LOGOUT)
- ));
+ this.props.dispatch(logout());
} else {
sendAnalytics(createProfilePanelButtonEvent('login.button'));
- APP.UI.emitEvent(UIEvents.AUTH_CLICKED);
+ this.props.dispatch(login());
}
}
@@ -246,4 +249,4 @@ class ProfileTab extends AbstractDialogTab<IProps, any> {
}
}
-export default withStyles(styles)(translate(ProfileTab));
+export default withStyles(styles)(translate(connect()(ProfileTab)));
diff --git a/react/features/video-layout/middleware.web.ts b/react/features/video-layout/middleware.web.ts
index a4c3c0db1e..2b4431137b 100644
--- a/react/features/video-layout/middleware.web.ts
+++ b/react/features/video-layout/middleware.web.ts
@@ -1,6 +1,6 @@
// @ts-expect-error
import VideoLayout from '../../../modules/UI/videolayout/VideoLayout.js';
-import { CONFERENCE_WILL_LEAVE } from '../base/conference/actionTypes';
+import { CONFERENCE_WILL_INIT, CONFERENCE_WILL_LEAVE } from '../base/conference/actionTypes';
import { MEDIA_TYPE } from '../base/media/constants';
import { PARTICIPANT_JOINED } from '../base/participants/actionTypes';
import { getLocalParticipant } from '../base/participants/functions';
@@ -25,6 +25,11 @@ MiddlewareRegistry.register(store => next => action => {
const result = next(action);
switch (action.type) {
+ case CONFERENCE_WILL_INIT:
+ // Reset VideoLayout. It's destroyed on CONFERENCE_WILL_LEAVE so re-initialize it.
+ VideoLayout.initLargeVideo();
+ VideoLayout.resizeVideoArea();
+ break;
case CONFERENCE_WILL_LEAVE:
VideoLayout.reset();
break;
diff --git a/service/UI/UIEvents.js b/service/UI/UIEvents.js
index 1ca4701e71..12b1fe5824 100644
--- a/service/UI/UIEvents.js
+++ b/service/UI/UIEvents.js
@@ -20,7 +20,6 @@ export default {
*/
TOGGLE_FULLSCREEN: 'UI.toogle_fullscreen',
FULLSCREEN_TOGGLED: 'UI.fullscreen_toggled',
- AUTH_CLICKED: 'UI.auth_clicked',
/**
* Notifies that the audio only mode was toggled.
@@ -41,7 +40,6 @@ export default {
TOGGLE_FILMSTRIP: 'UI.toggle_filmstrip',
HANGUP: 'UI.hangup',
- LOGOUT: 'UI.logout',
VIDEO_DEVICE_CHANGED: 'UI.video_device_changed',
AUDIO_DEVICE_CHANGED: 'UI.audio_device_changed',