2018-06-09 18:10:00 +02:00
|
|
|
// @flow
|
|
|
|
|
2018-06-23 01:36:48 +02:00
|
|
|
import { getAvatarURL } from 'js-utils';
|
2018-06-09 18:10:00 +02:00
|
|
|
|
2018-06-23 02:51:50 +02:00
|
|
|
import {
|
2018-07-01 06:25:06 +02:00
|
|
|
SET_AUDIO_MUTED,
|
2018-06-23 02:51:50 +02:00
|
|
|
SET_AVATAR_URL,
|
|
|
|
SET_EMAIL,
|
|
|
|
SET_NAME,
|
2018-07-01 06:25:06 +02:00
|
|
|
SET_SERVER_URL,
|
|
|
|
SET_VIDEO_MUTED
|
2018-06-23 02:51:50 +02:00
|
|
|
} from './actionTypes';
|
2018-06-09 18:10:00 +02:00
|
|
|
|
|
|
|
type State = {
|
|
|
|
avatarURL: string,
|
|
|
|
email: string,
|
2018-06-23 02:51:50 +02:00
|
|
|
name: string,
|
2018-07-01 06:25:06 +02:00
|
|
|
serverURL: ?string,
|
|
|
|
startWithAudioMuted: boolean,
|
|
|
|
startWithVideoMuted: boolean
|
2018-06-09 18:10:00 +02:00
|
|
|
};
|
|
|
|
|
2020-04-07 11:55:54 +02:00
|
|
|
const username = window.jitsiNodeAPI.osUserInfo().username;
|
2018-06-09 18:10:00 +02:00
|
|
|
|
|
|
|
const DEFAULT_STATE = {
|
|
|
|
avatarURL: getAvatarURL({ id: username }),
|
|
|
|
email: '',
|
2018-06-23 02:51:50 +02:00
|
|
|
name: username,
|
2018-07-01 06:25:06 +02:00
|
|
|
serverURL: undefined,
|
|
|
|
startWithAudioMuted: false,
|
|
|
|
startWithVideoMuted: false
|
2018-06-09 18:10:00 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reduces redux actions for features/settings.
|
|
|
|
*
|
|
|
|
* @param {State} state - Current reduced redux state.
|
|
|
|
* @param {Object} action - Action which was dispatched.
|
|
|
|
* @returns {State} - Updated reduced redux state.
|
|
|
|
*/
|
|
|
|
export default (state: State = DEFAULT_STATE, action: Object) => {
|
|
|
|
switch (action.type) {
|
2018-07-01 06:25:06 +02:00
|
|
|
case SET_AUDIO_MUTED:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
startWithAudioMuted: action.startWithAudioMuted
|
|
|
|
};
|
|
|
|
|
2018-06-09 18:10:00 +02:00
|
|
|
case SET_AVATAR_URL:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
avatarURL: action.avatarURL
|
|
|
|
};
|
|
|
|
|
|
|
|
case SET_EMAIL:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
email: action.email
|
|
|
|
};
|
|
|
|
|
|
|
|
case SET_NAME:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
name: action.name
|
|
|
|
};
|
|
|
|
|
2018-06-23 02:51:50 +02:00
|
|
|
case SET_SERVER_URL:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
serverURL: action.serverURL
|
|
|
|
};
|
|
|
|
|
2018-07-01 06:25:06 +02:00
|
|
|
case SET_VIDEO_MUTED:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
startWithVideoMuted: action.startWithVideoMuted
|
|
|
|
};
|
|
|
|
|
2018-06-09 18:10:00 +02:00
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
};
|