2018-08-09 23:00:03 +00:00
|
|
|
// @flow
|
|
|
|
|
2018-05-16 14:00:16 +00:00
|
|
|
import { JitsiRecordingConstants } from '../base/lib-jitsi-meet';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Searches in the passed in redux state for an active recording session of the
|
|
|
|
* passed in mode.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The redux state to search in.
|
|
|
|
* @param {string} mode - Find an active recording session of the given mode.
|
|
|
|
* @returns {Object|undefined}
|
|
|
|
*/
|
2018-08-09 23:00:03 +00:00
|
|
|
export function getActiveSession(state: Object, mode: string) {
|
2018-05-16 14:00:16 +00:00
|
|
|
const { sessionDatas } = state['features/recording'];
|
|
|
|
const { status: statusConstants } = JitsiRecordingConstants;
|
|
|
|
|
|
|
|
return sessionDatas.find(sessionData => sessionData.mode === mode
|
|
|
|
&& (sessionData.status === statusConstants.ON
|
|
|
|
|| sessionData.status === statusConstants.PENDING));
|
|
|
|
}
|
2018-06-05 18:20:43 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Searches in the passed in redux state for a recording session that matches
|
|
|
|
* the passed in recording session ID.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The redux state to search in.
|
|
|
|
* @param {string} id - The ID of the recording session to find.
|
|
|
|
* @returns {Object|undefined}
|
|
|
|
*/
|
2018-08-09 23:00:03 +00:00
|
|
|
export function getSessionById(state: Object, id: string) {
|
2018-06-05 18:20:43 +00:00
|
|
|
return state['features/recording'].sessionDatas.find(
|
|
|
|
sessionData => sessionData.id === id);
|
|
|
|
}
|