2022-08-26 09:54:16 +00:00
|
|
|
import PersistenceRegistry from '../base/redux/PersistenceRegistry';
|
|
|
|
import ReducerRegistry from '../base/redux/ReducerRegistry';
|
2020-04-16 10:47:10 +00:00
|
|
|
|
|
|
|
import {
|
2021-09-28 22:50:57 +00:00
|
|
|
PREJOIN_JOINING_IN_PROGRESS,
|
2020-04-16 10:47:10 +00:00
|
|
|
SET_DEVICE_STATUS,
|
2020-05-14 12:30:24 +00:00
|
|
|
SET_DIALOUT_COUNTRY,
|
2020-07-02 09:18:38 +00:00
|
|
|
SET_DIALOUT_NUMBER,
|
2020-05-14 12:30:24 +00:00
|
|
|
SET_DIALOUT_STATUS,
|
2020-04-16 10:47:10 +00:00
|
|
|
SET_JOIN_BY_PHONE_DIALOG_VISIBLITY,
|
2020-07-29 10:27:32 +00:00
|
|
|
SET_PRECALL_TEST_RESULTS,
|
2020-04-16 10:47:10 +00:00
|
|
|
SET_PREJOIN_DEVICE_ERRORS,
|
2020-07-02 09:18:38 +00:00
|
|
|
SET_PREJOIN_DISPLAY_NAME_REQUIRED,
|
|
|
|
SET_PREJOIN_PAGE_VISIBILITY,
|
2021-02-04 17:33:18 +00:00
|
|
|
SET_SKIP_PREJOIN_RELOAD
|
2020-04-16 10:47:10 +00:00
|
|
|
} from './actionTypes';
|
|
|
|
|
|
|
|
const DEFAULT_STATE = {
|
2020-05-14 12:30:24 +00:00
|
|
|
country: '',
|
2020-04-16 10:47:10 +00:00
|
|
|
deviceStatusText: 'prejoin.configuringDevices',
|
|
|
|
deviceStatusType: 'ok',
|
2020-05-14 12:30:24 +00:00
|
|
|
dialOutCountry: {
|
|
|
|
name: 'United States',
|
|
|
|
dialCode: '1',
|
|
|
|
code: 'us'
|
|
|
|
},
|
|
|
|
dialOutNumber: '',
|
|
|
|
dialOutStatus: 'prejoin.dialing',
|
2020-07-02 09:18:38 +00:00
|
|
|
isDisplayNameRequired: false,
|
2020-05-14 12:30:24 +00:00
|
|
|
name: '',
|
|
|
|
rawError: '',
|
2020-04-16 10:47:10 +00:00
|
|
|
showPrejoin: true,
|
2021-02-04 17:33:18 +00:00
|
|
|
skipPrejoinOnReload: false,
|
2021-11-04 08:17:55 +00:00
|
|
|
showJoinByPhoneDialog: false
|
2020-04-16 10:47:10 +00:00
|
|
|
};
|
|
|
|
|
2022-08-26 09:54:16 +00:00
|
|
|
export interface IPrejoinState {
|
|
|
|
country: string;
|
|
|
|
deviceStatusText: string;
|
|
|
|
deviceStatusType: string;
|
|
|
|
dialOutCountry: {
|
|
|
|
code: string;
|
|
|
|
dialCode: string;
|
|
|
|
name: string;
|
|
|
|
};
|
|
|
|
dialOutNumber: string;
|
|
|
|
dialOutStatus: string;
|
|
|
|
isDisplayNameRequired: boolean;
|
|
|
|
joiningInProgress?: boolean;
|
|
|
|
name: string;
|
2022-09-21 08:32:50 +00:00
|
|
|
precallTestResults?: {
|
|
|
|
fractionalLoss: number;
|
|
|
|
mediaConnectivity: boolean;
|
|
|
|
throughput: number;
|
|
|
|
};
|
2022-08-26 09:54:16 +00:00
|
|
|
rawError: string;
|
|
|
|
showJoinByPhoneDialog: boolean;
|
|
|
|
showPrejoin: boolean;
|
|
|
|
skipPrejoinOnReload: boolean;
|
|
|
|
}
|
2021-02-04 17:33:18 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets up the persistence of the feature {@code prejoin}.
|
|
|
|
*/
|
2022-08-26 09:54:16 +00:00
|
|
|
PersistenceRegistry.register('features/prejoin', {
|
2021-02-04 17:33:18 +00:00
|
|
|
skipPrejoinOnReload: true
|
|
|
|
}, DEFAULT_STATE);
|
|
|
|
|
2020-04-16 10:47:10 +00:00
|
|
|
/**
|
2021-11-04 21:10:43 +00:00
|
|
|
* Listen for actions that mutate the prejoin state.
|
2020-04-16 10:47:10 +00:00
|
|
|
*/
|
2022-09-05 09:05:07 +00:00
|
|
|
ReducerRegistry.register<IPrejoinState>(
|
|
|
|
'features/prejoin', (state = DEFAULT_STATE, action): IPrejoinState => {
|
2020-04-16 10:47:10 +00:00
|
|
|
switch (action.type) {
|
2021-09-28 22:50:57 +00:00
|
|
|
case PREJOIN_JOINING_IN_PROGRESS:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
joiningInProgress: action.value
|
|
|
|
};
|
2021-02-04 17:33:18 +00:00
|
|
|
case SET_SKIP_PREJOIN_RELOAD: {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
skipPrejoinOnReload: action.value
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-07-29 10:27:32 +00:00
|
|
|
case SET_PRECALL_TEST_RESULTS:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
precallTestResults: action.value
|
|
|
|
};
|
|
|
|
|
2020-04-16 10:47:10 +00:00
|
|
|
case SET_PREJOIN_PAGE_VISIBILITY:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
showPrejoin: action.value
|
|
|
|
};
|
|
|
|
|
|
|
|
case SET_PREJOIN_DEVICE_ERRORS: {
|
|
|
|
const status = getStatusFromErrors(action.value);
|
|
|
|
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
...status
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
case SET_DEVICE_STATUS: {
|
2020-08-12 07:19:31 +00:00
|
|
|
const { deviceStatusType, deviceStatusText } = action.value;
|
|
|
|
|
2020-04-16 10:47:10 +00:00
|
|
|
return {
|
|
|
|
...state,
|
2020-08-12 07:19:31 +00:00
|
|
|
deviceStatusText,
|
|
|
|
deviceStatusType
|
2020-04-16 10:47:10 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-05-14 12:30:24 +00:00
|
|
|
case SET_DIALOUT_NUMBER: {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
dialOutNumber: action.value
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
case SET_DIALOUT_COUNTRY: {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
dialOutCountry: action.value
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
case SET_DIALOUT_STATUS: {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
dialOutStatus: action.value
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-04-16 10:47:10 +00:00
|
|
|
case SET_JOIN_BY_PHONE_DIALOG_VISIBLITY: {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
showJoinByPhoneDialog: action.value
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-07-02 09:18:38 +00:00
|
|
|
case SET_PREJOIN_DISPLAY_NAME_REQUIRED: {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
isDisplayNameRequired: true
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-04-16 10:47:10 +00:00
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
2021-11-04 21:10:43 +00:00
|
|
|
}
|
2020-04-16 10:47:10 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a suitable error object based on the track errors.
|
|
|
|
*
|
|
|
|
* @param {Object} errors - The errors got while creating local tracks.
|
|
|
|
* @returns {Object}
|
|
|
|
*/
|
2022-08-26 09:54:16 +00:00
|
|
|
function getStatusFromErrors(errors: {
|
2022-09-08 09:52:36 +00:00
|
|
|
audioAndVideoError?: { message: string; };
|
|
|
|
audioOnlyError?: { message: string; };
|
|
|
|
videoOnlyError?: Object; }
|
2022-08-26 09:54:16 +00:00
|
|
|
) {
|
2020-04-16 10:47:10 +00:00
|
|
|
const { audioOnlyError, videoOnlyError, audioAndVideoError } = errors;
|
|
|
|
|
|
|
|
if (audioAndVideoError) {
|
|
|
|
if (audioOnlyError) {
|
|
|
|
if (videoOnlyError) {
|
|
|
|
return {
|
|
|
|
deviceStatusType: 'warning',
|
|
|
|
deviceStatusText: 'prejoin.audioAndVideoError',
|
|
|
|
rawError: audioAndVideoError.message
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
deviceStatusType: 'warning',
|
|
|
|
deviceStatusText: 'prejoin.audioOnlyError',
|
|
|
|
rawError: audioOnlyError.message
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
deviceStatusType: 'warning',
|
|
|
|
deviceStatusText: 'prejoin.videoOnlyError',
|
|
|
|
rawError: audioAndVideoError.message
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
deviceStatusType: 'ok',
|
|
|
|
deviceStatusText: 'prejoin.lookGood',
|
|
|
|
rawError: ''
|
|
|
|
};
|
|
|
|
}
|