mirror of
https://gitcode.com/GitHub_Trending/ji/jitsi-meet.git
synced 2026-05-13 21:32:31 +00:00
* fix: Drop duplicate call of wait for owner. * fix: Fixes leaking listeners while waiting for host to join. While waiting for the host to join on the dialog we attempt to join over and over again till we are admitted to enter the meeting. While doing that authRequired flag is on, and we were adding listeners on and on. * feat: Introduces conference join in progress action. This event is coming from lib-jitsi-meet and is fired when we receive the first presence of series when joining. It is always fired before joined event. * fix: Moves testing middleware to use CONFERENCE_JOIN_IN_PROGRESS. * fix: Moves follow-me middleware to use CONFERENCE_JOIN_IN_PROGRESS. * fix: Moves some polls logic to middleware and use CONFERENCE_JOIN_IN_PROGRESS. * fix: Moves reactions middleware to use CONFERENCE_JOIN_IN_PROGRESS. * fix: Moves recordings middleware to use CONFERENCE_JOIN_IN_PROGRESS. * fix: Moves shared-video middleware to use CONFERENCE_JOIN_IN_PROGRESS. * fix: Moves videosipgw middleware to use CONFERENCE_JOIN_IN_PROGRESS. * squash: Fix comments. * fix: Fixes join in progress on web. * fix: Moves variable extraction inside handlers. * fix: Moves variable extraction inside handlers again. * fix: Moves etherpad middleware to use CONFERENCE_JOIN_IN_PROGRESS.
153 lines
4.2 KiB
JavaScript
153 lines
4.2 KiB
JavaScript
// @flow
|
|
|
|
import { maybeRedirectToWelcomePage } from '../app/actions';
|
|
import {
|
|
CONFERENCE_FAILED,
|
|
CONFERENCE_JOINED,
|
|
CONFERENCE_LEFT
|
|
} from '../base/conference';
|
|
import { CONNECTION_ESTABLISHED } from '../base/connection';
|
|
import { hideDialog, isDialogOpen } from '../base/dialog';
|
|
import {
|
|
JitsiConferenceErrors
|
|
} from '../base/lib-jitsi-meet';
|
|
import { MiddlewareRegistry } from '../base/redux';
|
|
|
|
import {
|
|
CANCEL_LOGIN,
|
|
STOP_WAIT_FOR_OWNER,
|
|
UPGRADE_ROLE_FINISHED,
|
|
WAIT_FOR_OWNER
|
|
} from './actionTypes';
|
|
import {
|
|
hideLoginDialog,
|
|
openWaitForOwnerDialog,
|
|
stopWaitForOwner
|
|
} from './actions.web';
|
|
import { LoginDialog, WaitForOwnerDialog } from './components';
|
|
|
|
/**
|
|
* 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'];
|
|
|
|
// Only end the meeting if we are not already inside and trying to upgrade.
|
|
if (authRequired && !conference) {
|
|
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:
|
|
if (_isWaitingForOwner(store)) {
|
|
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 } = 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 }: { getState: Function }) {
|
|
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 }: { getState: Function }) {
|
|
return getState()['features/authentication'].waitForOwnerTimeoutID;
|
|
}
|