2018-05-01 04:43:47 +00:00
|
|
|
// @flow
|
|
|
|
|
2019-01-18 10:56:18 +00:00
|
|
|
import { ReducerRegistry } from '../base/redux';
|
2017-04-20 23:28:03 +00:00
|
|
|
|
|
|
|
import {
|
2018-06-26 22:56:22 +00:00
|
|
|
ADD_PENDING_INVITE_REQUEST,
|
|
|
|
REMOVE_PENDING_INVITE_REQUESTS,
|
|
|
|
SET_CALLEE_INFO_VISIBLE,
|
2019-02-26 10:41:57 +00:00
|
|
|
SET_INVITE_DIALOG_VISIBLE,
|
2017-04-20 23:28:03 +00:00
|
|
|
UPDATE_DIAL_IN_NUMBERS_FAILED,
|
|
|
|
UPDATE_DIAL_IN_NUMBERS_SUCCESS
|
|
|
|
} from './actionTypes';
|
|
|
|
|
2019-02-26 13:32:46 +00:00
|
|
|
const logger = require('jitsi-meet-logger').getLogger(__filename);
|
|
|
|
|
2017-04-20 23:28:03 +00:00
|
|
|
const DEFAULT_STATE = {
|
2018-06-26 22:56:22 +00:00
|
|
|
/**
|
|
|
|
* The indicator which determines whether (the) {@code CalleeInfo} is
|
|
|
|
* visible.
|
|
|
|
*
|
|
|
|
* @type {boolean|undefined}
|
|
|
|
*/
|
|
|
|
calleeInfoVisible: false,
|
2019-02-26 10:41:57 +00:00
|
|
|
inviteDialogVisible: false,
|
2018-06-26 22:56:22 +00:00
|
|
|
numbersEnabled: true,
|
|
|
|
pendingInviteRequests: []
|
2017-04-20 23:28:03 +00:00
|
|
|
};
|
|
|
|
|
2017-05-31 05:32:13 +00:00
|
|
|
ReducerRegistry.register('features/invite', (state = DEFAULT_STATE, action) => {
|
|
|
|
switch (action.type) {
|
2018-06-26 22:56:22 +00:00
|
|
|
case ADD_PENDING_INVITE_REQUEST:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
pendingInviteRequests: [
|
|
|
|
...state.pendingInviteRequests,
|
|
|
|
action.request
|
|
|
|
]
|
|
|
|
};
|
2019-01-18 10:56:18 +00:00
|
|
|
|
2018-06-26 22:56:22 +00:00
|
|
|
case REMOVE_PENDING_INVITE_REQUESTS:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
pendingInviteRequests: []
|
|
|
|
};
|
|
|
|
|
|
|
|
case SET_CALLEE_INFO_VISIBLE:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
calleeInfoVisible: action.calleeInfoVisible,
|
|
|
|
initialCalleeInfo: action.initialCalleeInfo
|
|
|
|
};
|
2018-05-01 04:43:47 +00:00
|
|
|
|
2019-02-26 10:41:57 +00:00
|
|
|
case SET_INVITE_DIALOG_VISIBLE:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
inviteDialogVisible: action.visible
|
|
|
|
};
|
|
|
|
|
2017-05-31 05:32:13 +00:00
|
|
|
case UPDATE_DIAL_IN_NUMBERS_FAILED:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
error: action.error
|
|
|
|
};
|
2017-04-20 23:28:03 +00:00
|
|
|
|
2017-05-31 05:32:13 +00:00
|
|
|
case UPDATE_DIAL_IN_NUMBERS_SUCCESS: {
|
2019-02-26 13:32:46 +00:00
|
|
|
if (Array.isArray(action.dialInNumbers)) {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
conferenceID: action.conferenceID,
|
|
|
|
numbers: action.dialInNumbers,
|
|
|
|
numbersEnabled: true
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
// this is the old format which is deprecated
|
|
|
|
logger.warn('Using deprecated API for retrieving phone numbers');
|
|
|
|
|
|
|
|
const { numbersEnabled } = action.dialInNumbers;
|
2017-04-20 23:28:03 +00:00
|
|
|
|
2017-05-31 05:32:13 +00:00
|
|
|
return {
|
2018-02-13 19:46:47 +00:00
|
|
|
...state,
|
2017-05-31 05:32:13 +00:00
|
|
|
conferenceID: action.conferenceID,
|
2019-02-26 13:32:46 +00:00
|
|
|
numbers: action.dialInNumbers,
|
2017-05-31 05:32:13 +00:00
|
|
|
numbersEnabled
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
2017-04-20 23:28:03 +00:00
|
|
|
|
2017-05-31 05:32:13 +00:00
|
|
|
return state;
|
|
|
|
});
|