2022-08-10 09:56:24 +00:00
|
|
|
import ReducerRegistry from '../base/redux/ReducerRegistry';
|
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,
|
2017-04-20 23:28:03 +00:00
|
|
|
UPDATE_DIAL_IN_NUMBERS_FAILED,
|
|
|
|
UPDATE_DIAL_IN_NUMBERS_SUCCESS
|
|
|
|
} from './actionTypes';
|
2019-08-21 14:50:00 +00:00
|
|
|
import logger from './logger';
|
2022-12-14 12:23:07 +00:00
|
|
|
import { IInvitee } from './types';
|
2019-02-26 13:32:46 +00:00
|
|
|
|
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,
|
|
|
|
numbersEnabled: true,
|
2020-05-14 12:30:24 +00:00
|
|
|
numbersFetched: false,
|
2018-06-26 22:56:22 +00:00
|
|
|
pendingInviteRequests: []
|
2017-04-20 23:28:03 +00:00
|
|
|
};
|
|
|
|
|
2022-08-10 09:56:24 +00:00
|
|
|
export interface IInviteState {
|
|
|
|
calleeInfoVisible?: boolean;
|
2022-10-31 07:56:26 +00:00
|
|
|
conferenceID?: string | number;
|
2022-08-10 09:56:24 +00:00
|
|
|
error?: Error;
|
|
|
|
initialCalleeInfo?: Object;
|
2022-12-14 12:23:07 +00:00
|
|
|
numbers?: string[];
|
2022-08-10 09:56:24 +00:00
|
|
|
numbersEnabled: boolean;
|
|
|
|
numbersFetched: boolean;
|
|
|
|
pendingInviteRequests: Array<{
|
|
|
|
callback: Function;
|
2022-12-14 12:23:07 +00:00
|
|
|
invitees: IInvitee[];
|
2022-08-10 09:56:24 +00:00
|
|
|
}>;
|
|
|
|
sipUri?: string;
|
|
|
|
}
|
|
|
|
|
2022-09-05 09:05:07 +00:00
|
|
|
ReducerRegistry.register<IInviteState>('features/invite', (state = DEFAULT_STATE, action): IInviteState => {
|
2017-05-31 05:32:13 +00:00
|
|
|
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
|
|
|
|
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,
|
2021-05-12 13:21:22 +00:00
|
|
|
sipUri: action.sipUri,
|
2020-05-14 12:30:24 +00:00
|
|
|
numbersEnabled: true,
|
|
|
|
numbersFetched: true
|
2019-02-26 13:32:46 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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,
|
2020-05-14 12:30:24 +00:00
|
|
|
numbersEnabled,
|
|
|
|
numbersFetched: true
|
2017-05-31 05:32:13 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
2017-04-20 23:28:03 +00:00
|
|
|
|
2017-05-31 05:32:13 +00:00
|
|
|
return state;
|
|
|
|
});
|