You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
124 lines
2.4 KiB
124 lines
2.4 KiB
const initialState =
|
|
{
|
|
id : null,
|
|
displayName : null,
|
|
displayNameSet : false,
|
|
device : null,
|
|
canSendMic : false,
|
|
canSendWebcam : false,
|
|
canChangeWebcam : false,
|
|
webcamInProgress : false,
|
|
shareInProgress : false,
|
|
audioOnly : false,
|
|
audioOnlyInProgress : false,
|
|
audioMuted : false,
|
|
restartIceInProgress : false
|
|
};
|
|
|
|
const me = (state = initialState, action) =>
|
|
{
|
|
switch (action.type)
|
|
{
|
|
case 'SET_ROOM_STATE':
|
|
{
|
|
const roomState = action.payload.state;
|
|
|
|
if (roomState === 'closed')
|
|
{
|
|
return {
|
|
...state,
|
|
webcamInProgress : false,
|
|
shareInProgress : false,
|
|
audioOnly : false,
|
|
audioOnlyInProgress : false,
|
|
audioMuted : false,
|
|
restartIceInProgress : false
|
|
};
|
|
}
|
|
else
|
|
{
|
|
return state;
|
|
}
|
|
}
|
|
|
|
case 'SET_ME':
|
|
{
|
|
const { peerId, displayName, displayNameSet, device } = action.payload;
|
|
|
|
return { ...state, id: peerId, displayName, displayNameSet, device };
|
|
}
|
|
|
|
case 'SET_MEDIA_CAPABILITIES':
|
|
{
|
|
const { canSendMic, canSendWebcam } = action.payload;
|
|
|
|
return { ...state, canSendMic, canSendWebcam };
|
|
}
|
|
|
|
case 'SET_CAN_CHANGE_WEBCAM':
|
|
{
|
|
const canChangeWebcam = action.payload;
|
|
|
|
return { ...state, canChangeWebcam };
|
|
}
|
|
|
|
case 'SET_WEBCAM_IN_PROGRESS':
|
|
{
|
|
const { flag } = action.payload;
|
|
|
|
return { ...state, webcamInProgress: flag };
|
|
}
|
|
|
|
case 'SET_SHARE_IN_PROGRESS':
|
|
{
|
|
const { flag } = action.payload;
|
|
|
|
return { ...state, shareInProgress: flag };
|
|
}
|
|
|
|
case 'SET_DISPLAY_NAME':
|
|
{
|
|
let { displayName } = action.payload;
|
|
|
|
// Be ready for undefined displayName (so keep previous one).
|
|
if (!displayName)
|
|
displayName = state.displayName;
|
|
|
|
return { ...state, displayName, displayNameSet: true };
|
|
}
|
|
|
|
case 'SET_AUDIO_ONLY_STATE':
|
|
{
|
|
const { enabled } = action.payload;
|
|
|
|
return { ...state, audioOnly: enabled };
|
|
}
|
|
|
|
case 'SET_AUDIO_ONLY_IN_PROGRESS':
|
|
{
|
|
const { flag } = action.payload;
|
|
|
|
return { ...state, audioOnlyInProgress: flag };
|
|
}
|
|
|
|
case 'SET_AUDIO_MUTED_STATE':
|
|
{
|
|
const { enabled } = action.payload;
|
|
|
|
return { ...state, audioMuted: enabled };
|
|
}
|
|
|
|
case 'SET_RESTART_ICE_IN_PROGRESS':
|
|
{
|
|
const { flag } = action.payload;
|
|
|
|
return { ...state, restartIceInProgress: flag };
|
|
}
|
|
|
|
default:
|
|
return state;
|
|
}
|
|
};
|
|
|
|
export default me;
|