mirror of
https://gitcode.com/GitHub_Trending/ji/jitsi-meet.git
synced 2026-05-14 11:37:48 +00:00
feat(prejoin_page): Add prejoin page
This commit is contained in:
committed by
Saúl Ibarra Corretgé
parent
5b53232964
commit
a45cbf41ef
168
react/features/prejoin/reducer.js
Normal file
168
react/features/prejoin/reducer.js
Normal file
@@ -0,0 +1,168 @@
|
||||
import { ReducerRegistry } from '../base/redux';
|
||||
|
||||
import {
|
||||
ADD_PREJOIN_AUDIO_TRACK,
|
||||
ADD_PREJOIN_CONTENT_SHARING_TRACK,
|
||||
ADD_PREJOIN_VIDEO_TRACK,
|
||||
SET_DEVICE_STATUS,
|
||||
SET_JOIN_BY_PHONE_DIALOG_VISIBLITY,
|
||||
SET_PREJOIN_AUDIO_DISABLED,
|
||||
SET_PREJOIN_AUDIO_MUTED,
|
||||
SET_PREJOIN_DEVICE_ERRORS,
|
||||
SET_PREJOIN_NAME,
|
||||
SET_PREJOIN_PAGE_VISIBILITY,
|
||||
SET_PREJOIN_VIDEO_DISABLED,
|
||||
SET_PREJOIN_VIDEO_MUTED
|
||||
} from './actionTypes';
|
||||
|
||||
const DEFAULT_STATE = {
|
||||
audioDisabled: false,
|
||||
audioMuted: false,
|
||||
videoMuted: false,
|
||||
videoDisabled: false,
|
||||
deviceStatusText: 'prejoin.configuringDevices',
|
||||
deviceStatusType: 'ok',
|
||||
showPrejoin: true,
|
||||
showJoinByPhoneDialog: false,
|
||||
videoTrack: null,
|
||||
audioTrack: null,
|
||||
contentSharingTrack: null,
|
||||
rawError: '',
|
||||
name: ''
|
||||
};
|
||||
|
||||
/**
|
||||
* Listen for actions that mutate the prejoin state
|
||||
*/
|
||||
ReducerRegistry.register(
|
||||
'features/prejoin', (state = DEFAULT_STATE, action) => {
|
||||
switch (action.type) {
|
||||
case ADD_PREJOIN_AUDIO_TRACK: {
|
||||
return {
|
||||
...state,
|
||||
audioTrack: action.value
|
||||
};
|
||||
}
|
||||
|
||||
case ADD_PREJOIN_CONTENT_SHARING_TRACK: {
|
||||
return {
|
||||
...state,
|
||||
contentSharingTrack: action.value
|
||||
};
|
||||
}
|
||||
|
||||
case ADD_PREJOIN_VIDEO_TRACK: {
|
||||
return {
|
||||
...state,
|
||||
videoTrack: action.value
|
||||
};
|
||||
}
|
||||
|
||||
case SET_PREJOIN_NAME: {
|
||||
return {
|
||||
...state,
|
||||
name: action.value
|
||||
};
|
||||
}
|
||||
|
||||
case SET_PREJOIN_PAGE_VISIBILITY:
|
||||
return {
|
||||
...state,
|
||||
showPrejoin: action.value
|
||||
};
|
||||
|
||||
case SET_PREJOIN_VIDEO_DISABLED: {
|
||||
return {
|
||||
...state,
|
||||
videoDisabled: action.value
|
||||
};
|
||||
}
|
||||
|
||||
case SET_PREJOIN_VIDEO_MUTED:
|
||||
return {
|
||||
...state,
|
||||
videoMuted: action.value
|
||||
};
|
||||
|
||||
case SET_PREJOIN_AUDIO_MUTED:
|
||||
return {
|
||||
...state,
|
||||
audioMuted: action.value
|
||||
};
|
||||
|
||||
case SET_PREJOIN_DEVICE_ERRORS: {
|
||||
const status = getStatusFromErrors(action.value);
|
||||
|
||||
return {
|
||||
...state,
|
||||
...status
|
||||
};
|
||||
}
|
||||
|
||||
case SET_DEVICE_STATUS: {
|
||||
return {
|
||||
...state,
|
||||
deviceStatusText: action.text,
|
||||
deviceStatusType: action.type
|
||||
};
|
||||
}
|
||||
|
||||
case SET_PREJOIN_AUDIO_DISABLED: {
|
||||
return {
|
||||
...state,
|
||||
audioDisabled: true
|
||||
};
|
||||
}
|
||||
|
||||
case SET_JOIN_BY_PHONE_DIALOG_VISIBLITY: {
|
||||
return {
|
||||
...state,
|
||||
showJoinByPhoneDialog: action.value
|
||||
};
|
||||
}
|
||||
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
/**
|
||||
* Returns a suitable error object based on the track errors.
|
||||
*
|
||||
* @param {Object} errors - The errors got while creating local tracks.
|
||||
* @returns {Object}
|
||||
*/
|
||||
function getStatusFromErrors(errors) {
|
||||
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: ''
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user