snapshot of https://github.com/jitsi/jitsi-meet.git @ fd1749dd28f4138aa80234fc7f311b19aaffa0e7 (2026-09-15)
This commit is contained in:
103
react/features/authentication/reducer.ts
Normal file
103
react/features/authentication/reducer.ts
Normal file
@@ -0,0 +1,103 @@
|
||||
import ReducerRegistry from '../base/redux/ReducerRegistry';
|
||||
import { assign } from '../base/redux/functions';
|
||||
|
||||
import {
|
||||
CANCEL_LOGIN,
|
||||
DISABLE_MODERATOR_LOGIN,
|
||||
ENABLE_MODERATOR_LOGIN,
|
||||
SET_TOKEN_AUTH_PENDING,
|
||||
STOP_WAIT_FOR_OWNER,
|
||||
UPGRADE_ROLE_FINISHED,
|
||||
UPGRADE_ROLE_STARTED,
|
||||
WAIT_FOR_OWNER
|
||||
} from './actionTypes';
|
||||
|
||||
export interface IAuthenticationState {
|
||||
error?: Object | undefined;
|
||||
progress?: number | undefined;
|
||||
showModeratorLogin?: boolean;
|
||||
thenableWithCancel?: {
|
||||
cancel: Function;
|
||||
};
|
||||
tokenAuthPending?: boolean;
|
||||
waitForOwnerTimeoutID?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Listens for actions which change the state of the authentication feature.
|
||||
*
|
||||
* @param {Object} state - The Redux state of the authentication feature.
|
||||
* @param {Object} action - Action object.
|
||||
* @param {string} action.type - Type of action.
|
||||
* @returns {Object}
|
||||
*/
|
||||
ReducerRegistry.register<IAuthenticationState>('features/authentication',
|
||||
(state = {}, action): IAuthenticationState => {
|
||||
switch (action.type) {
|
||||
case CANCEL_LOGIN:
|
||||
return assign(state, {
|
||||
error: undefined,
|
||||
progress: undefined,
|
||||
thenableWithCancel: undefined,
|
||||
tokenAuthPending: undefined
|
||||
});
|
||||
|
||||
case SET_TOKEN_AUTH_PENDING:
|
||||
return assign(state, {
|
||||
tokenAuthPending: action.pending || undefined
|
||||
});
|
||||
case ENABLE_MODERATOR_LOGIN:
|
||||
return assign(state, {
|
||||
showModeratorLogin: true
|
||||
});
|
||||
|
||||
case STOP_WAIT_FOR_OWNER:
|
||||
return assign(state, {
|
||||
error: undefined,
|
||||
waitForOwnerTimeoutID: undefined
|
||||
});
|
||||
|
||||
case DISABLE_MODERATOR_LOGIN:
|
||||
return assign(state, {
|
||||
error: undefined,
|
||||
showModeratorLogin: false
|
||||
});
|
||||
|
||||
case UPGRADE_ROLE_FINISHED: {
|
||||
let { thenableWithCancel } = action;
|
||||
|
||||
if (state.thenableWithCancel === thenableWithCancel) {
|
||||
const { error, progress } = action;
|
||||
|
||||
// An error interrupts the process of authenticating and upgrading
|
||||
// the role of the local participant/user i.e. the process is no
|
||||
// more. Obviously, the process seizes to exist also when it does
|
||||
// its whole job.
|
||||
if (error || progress === 1) {
|
||||
thenableWithCancel = undefined;
|
||||
}
|
||||
|
||||
return assign(state, {
|
||||
error,
|
||||
progress: progress || undefined,
|
||||
thenableWithCancel
|
||||
});
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case UPGRADE_ROLE_STARTED:
|
||||
return assign(state, {
|
||||
error: undefined,
|
||||
progress: undefined,
|
||||
thenableWithCancel: action.thenableWithCancel
|
||||
});
|
||||
|
||||
case WAIT_FOR_OWNER:
|
||||
return assign(state, {
|
||||
waitForOwnerTimeoutID: action.waitForOwnerTimeoutID
|
||||
});
|
||||
}
|
||||
|
||||
return state;
|
||||
});
|
||||
Reference in New Issue
Block a user