2022-09-01 11:00:49 +00:00
|
|
|
import ReducerRegistry from '../base/redux/ReducerRegistry';
|
2020-05-20 10:57:03 +00:00
|
|
|
|
2018-06-14 09:15:36 +00:00
|
|
|
import {
|
|
|
|
CLEAR_RECORDING_SESSIONS,
|
|
|
|
RECORDING_SESSION_UPDATED,
|
2022-03-14 08:31:08 +00:00
|
|
|
SET_MEETING_HIGHLIGHT_BUTTON_STATE,
|
2018-07-05 11:17:45 +00:00
|
|
|
SET_PENDING_RECORDING_NOTIFICATION_UID,
|
2021-06-23 08:57:11 +00:00
|
|
|
SET_SELECTED_RECORDING_SERVICE,
|
2018-07-05 11:17:45 +00:00
|
|
|
SET_STREAM_KEY
|
2018-06-14 09:15:36 +00:00
|
|
|
} from './actionTypes';
|
2018-05-16 14:00:16 +00:00
|
|
|
|
|
|
|
const DEFAULT_STATE = {
|
2022-03-14 08:31:08 +00:00
|
|
|
disableHighlightMeetingMoment: false,
|
2018-07-05 11:17:45 +00:00
|
|
|
pendingNotificationUids: {},
|
2021-06-23 08:57:11 +00:00
|
|
|
selectedRecordingService: '',
|
2018-05-16 14:00:16 +00:00
|
|
|
sessionDatas: []
|
|
|
|
};
|
2017-08-25 16:45:30 +00:00
|
|
|
|
2022-10-20 09:11:27 +00:00
|
|
|
interface ISessionData {
|
2022-09-01 11:00:49 +00:00
|
|
|
error?: Error;
|
|
|
|
id?: string;
|
2022-11-11 08:20:33 +00:00
|
|
|
initiator?: { getId: Function; };
|
2022-09-01 11:00:49 +00:00
|
|
|
liveStreamViewURL?: string;
|
|
|
|
mode?: string;
|
|
|
|
status?: string;
|
2022-11-11 08:20:33 +00:00
|
|
|
terminator?: { getId: Function; };
|
2022-09-01 11:00:49 +00:00
|
|
|
timestamp?: number;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface IRecordingState {
|
|
|
|
disableHighlightMeetingMoment: boolean;
|
|
|
|
pendingNotificationUids: {
|
2022-11-11 08:20:33 +00:00
|
|
|
[key: string]: string | undefined;
|
2022-09-01 11:00:49 +00:00
|
|
|
};
|
|
|
|
selectedRecordingService: string;
|
2022-10-20 09:11:27 +00:00
|
|
|
sessionDatas: Array<ISessionData>;
|
2022-09-01 11:00:49 +00:00
|
|
|
streamKey?: string;
|
|
|
|
}
|
|
|
|
|
2018-07-05 11:17:45 +00:00
|
|
|
/**
|
|
|
|
* The name of the Redux store this feature stores its state in.
|
|
|
|
*/
|
|
|
|
const STORE_NAME = 'features/recording';
|
|
|
|
|
2017-08-25 16:45:30 +00:00
|
|
|
/**
|
|
|
|
* Reduces the Redux actions of the feature features/recording.
|
|
|
|
*/
|
2022-09-05 09:05:07 +00:00
|
|
|
ReducerRegistry.register<IRecordingState>(STORE_NAME,
|
|
|
|
(state = DEFAULT_STATE, action): IRecordingState => {
|
2018-05-16 14:00:16 +00:00
|
|
|
switch (action.type) {
|
2018-06-14 09:15:36 +00:00
|
|
|
|
|
|
|
case CLEAR_RECORDING_SESSIONS:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
sessionDatas: []
|
|
|
|
};
|
|
|
|
|
2018-05-16 14:00:16 +00:00
|
|
|
case RECORDING_SESSION_UPDATED:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
sessionDatas:
|
|
|
|
_updateSessionDatas(state.sessionDatas, action.sessionData)
|
|
|
|
};
|
2017-08-25 16:45:30 +00:00
|
|
|
|
2018-07-05 11:17:45 +00:00
|
|
|
case SET_PENDING_RECORDING_NOTIFICATION_UID: {
|
|
|
|
const pendingNotificationUids = {
|
|
|
|
...state.pendingNotificationUids
|
|
|
|
};
|
|
|
|
|
|
|
|
pendingNotificationUids[action.streamType] = action.uid;
|
|
|
|
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
pendingNotificationUids
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-06-23 08:57:11 +00:00
|
|
|
case SET_SELECTED_RECORDING_SERVICE: {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
selectedRecordingService: action.selectedRecordingService
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2018-07-05 11:17:45 +00:00
|
|
|
case SET_STREAM_KEY:
|
2018-06-14 09:15:36 +00:00
|
|
|
return {
|
|
|
|
...state,
|
2018-07-05 11:17:45 +00:00
|
|
|
streamKey: action.streamKey
|
2018-06-14 09:15:36 +00:00
|
|
|
};
|
|
|
|
|
2022-03-14 08:31:08 +00:00
|
|
|
case SET_MEETING_HIGHLIGHT_BUTTON_STATE:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
disableHighlightMeetingMoment: action.disabled
|
|
|
|
};
|
|
|
|
|
2018-05-16 14:00:16 +00:00
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
});
|
2017-08-25 16:45:30 +00:00
|
|
|
|
2018-05-16 14:00:16 +00:00
|
|
|
/**
|
|
|
|
* Updates the known information on recording sessions.
|
|
|
|
*
|
|
|
|
* @param {Array} sessionDatas - The current sessions in the redux store.
|
|
|
|
* @param {Object} newSessionData - The updated session data.
|
|
|
|
* @private
|
|
|
|
* @returns {Array} The session datas with the updated session data added.
|
|
|
|
*/
|
2022-10-20 09:11:27 +00:00
|
|
|
function _updateSessionDatas(sessionDatas: ISessionData[], newSessionData: ISessionData) {
|
2018-05-16 14:00:16 +00:00
|
|
|
const hasExistingSessionData = sessionDatas.find(
|
|
|
|
sessionData => sessionData.id === newSessionData.id);
|
|
|
|
let newSessionDatas;
|
2018-03-07 00:28:19 +00:00
|
|
|
|
2018-05-16 14:00:16 +00:00
|
|
|
if (hasExistingSessionData) {
|
|
|
|
newSessionDatas = sessionDatas.map(sessionData => {
|
|
|
|
if (sessionData.id === newSessionData.id) {
|
|
|
|
return {
|
|
|
|
...newSessionData
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
// Nothing to update for this session data so pass it back in.
|
|
|
|
return sessionData;
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
// If the session data is not present, then there is nothing to update
|
|
|
|
// and instead it needs to be added to the known session datas.
|
|
|
|
newSessionDatas = [
|
|
|
|
...sessionDatas,
|
|
|
|
{ ...newSessionData }
|
|
|
|
];
|
2017-08-25 16:45:30 +00:00
|
|
|
}
|
2018-05-16 14:00:16 +00:00
|
|
|
|
|
|
|
return newSessionDatas;
|
|
|
|
}
|