2018-06-14 09:15:36 +00:00
|
|
|
// @flow
|
|
|
|
|
2018-07-05 11:17:45 +00:00
|
|
|
import JitsiMeetJS from '../base/lib-jitsi-meet';
|
|
|
|
|
2018-06-14 09:15:36 +00:00
|
|
|
import {
|
|
|
|
hideNotification,
|
|
|
|
showErrorNotification,
|
|
|
|
showNotification
|
|
|
|
} from '../notifications';
|
|
|
|
|
|
|
|
import {
|
|
|
|
CLEAR_RECORDING_SESSIONS,
|
|
|
|
RECORDING_SESSION_UPDATED,
|
2018-07-05 11:17:45 +00:00
|
|
|
SET_PENDING_RECORDING_NOTIFICATION_UID,
|
|
|
|
SET_STREAM_KEY
|
2018-06-14 09:15:36 +00:00
|
|
|
} from './actionTypes';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Clears the data of every recording sessions.
|
|
|
|
*
|
|
|
|
* @returns {{
|
|
|
|
* type: CLEAR_RECORDING_SESSIONS
|
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
export function clearRecordingSessions() {
|
|
|
|
return {
|
|
|
|
type: CLEAR_RECORDING_SESSIONS
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Signals that the pending recording notification should be removed from the
|
|
|
|
* screen.
|
|
|
|
*
|
2018-07-05 11:17:45 +00:00
|
|
|
* @param {string} streamType - The type of the stream (e.g. file or stream).
|
2018-06-14 09:15:36 +00:00
|
|
|
* @returns {Function}
|
|
|
|
*/
|
2018-07-05 11:17:45 +00:00
|
|
|
export function hidePendingRecordingNotification(streamType: string) {
|
2018-06-14 09:15:36 +00:00
|
|
|
return (dispatch: Function, getState: Function) => {
|
2018-07-05 11:17:45 +00:00
|
|
|
const { pendingNotificationUids } = getState()['features/recording'];
|
|
|
|
const pendingNotificationUid = pendingNotificationUids[streamType];
|
2018-06-14 09:15:36 +00:00
|
|
|
|
|
|
|
if (pendingNotificationUid) {
|
|
|
|
dispatch(hideNotification(pendingNotificationUid));
|
2018-07-05 11:17:45 +00:00
|
|
|
dispatch(
|
|
|
|
_setPendingRecordingNotificationUid(
|
|
|
|
undefined, streamType));
|
2018-06-14 09:15:36 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-07-05 11:17:45 +00:00
|
|
|
* Sets the stream key last used by the user for later reuse.
|
2018-06-14 09:15:36 +00:00
|
|
|
*
|
2018-07-05 11:17:45 +00:00
|
|
|
* @param {string} streamKey - The stream key to set.
|
2018-06-14 09:15:36 +00:00
|
|
|
* redux.
|
|
|
|
* @returns {{
|
2018-07-05 11:17:45 +00:00
|
|
|
* type: SET_STREAM_KEY,
|
|
|
|
* streamKey: string
|
2018-06-14 09:15:36 +00:00
|
|
|
* }}
|
|
|
|
*/
|
2018-07-05 11:17:45 +00:00
|
|
|
export function setLiveStreamKey(streamKey: string) {
|
2018-06-14 09:15:36 +00:00
|
|
|
return {
|
2018-07-05 11:17:45 +00:00
|
|
|
type: SET_STREAM_KEY,
|
|
|
|
streamKey
|
2018-06-14 09:15:36 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Signals that the pending recording notification should be shown on the
|
|
|
|
* screen.
|
|
|
|
*
|
2018-07-05 11:17:45 +00:00
|
|
|
* @param {string} streamType - The type of the stream (e.g. file or stream).
|
2018-06-14 09:15:36 +00:00
|
|
|
* @returns {Function}
|
|
|
|
*/
|
2018-07-05 11:17:45 +00:00
|
|
|
export function showPendingRecordingNotification(streamType: string) {
|
2018-06-14 09:15:36 +00:00
|
|
|
return (dispatch: Function) => {
|
2018-07-05 11:17:45 +00:00
|
|
|
const isLiveStreaming
|
|
|
|
= streamType === JitsiMeetJS.constants.recording.mode.STREAM;
|
|
|
|
const dialogProps = isLiveStreaming ? {
|
|
|
|
descriptionKey: 'liveStreaming.pending',
|
|
|
|
titleKey: 'dialog.liveStreaming'
|
|
|
|
} : {
|
2018-06-14 09:15:36 +00:00
|
|
|
descriptionKey: 'recording.pending',
|
|
|
|
titleKey: 'dialog.recording'
|
2018-07-05 11:17:45 +00:00
|
|
|
};
|
|
|
|
const showNotificationAction = showNotification({
|
|
|
|
isDismissAllowed: false,
|
|
|
|
...dialogProps
|
2018-06-14 09:15:36 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
dispatch(showNotificationAction);
|
|
|
|
|
2018-07-05 11:17:45 +00:00
|
|
|
dispatch(_setPendingRecordingNotificationUid(
|
|
|
|
showNotificationAction.uid, streamType));
|
2018-06-14 09:15:36 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Signals that the recording error notification should be shown.
|
|
|
|
*
|
|
|
|
* @param {Object} props - The Props needed to render the notification.
|
|
|
|
* @returns {showErrorNotification}
|
|
|
|
*/
|
|
|
|
export function showRecordingError(props: Object) {
|
|
|
|
return showErrorNotification(props);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Signals that the stopped recording notification should be shown on the
|
|
|
|
* screen for a given period.
|
|
|
|
*
|
2018-07-05 11:17:45 +00:00
|
|
|
* @param {string} streamType - The type of the stream (e.g. file or stream).
|
2018-06-14 09:15:36 +00:00
|
|
|
* @returns {showNotification}
|
|
|
|
*/
|
2018-07-05 11:17:45 +00:00
|
|
|
export function showStoppedRecordingNotification(streamType: string) {
|
|
|
|
const isLiveStreaming
|
|
|
|
= streamType === JitsiMeetJS.constants.recording.mode.STREAM;
|
|
|
|
const dialogProps = isLiveStreaming ? {
|
|
|
|
descriptionKey: 'liveStreaming.off',
|
|
|
|
titleKey: 'dialog.liveStreaming'
|
|
|
|
} : {
|
2018-06-14 09:15:36 +00:00
|
|
|
descriptionKey: 'recording.off',
|
|
|
|
titleKey: 'dialog.recording'
|
2018-07-05 11:17:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
return showNotification(dialogProps, 2500);
|
2018-06-14 09:15:36 +00:00
|
|
|
}
|
2017-08-25 16:45:30 +00:00
|
|
|
|
|
|
|
/**
|
2018-05-16 14:00:16 +00:00
|
|
|
* Updates the known state for a given recording session.
|
2017-08-25 16:45:30 +00:00
|
|
|
*
|
2018-05-16 14:00:16 +00:00
|
|
|
* @param {Object} session - The new state to merge with the existing state in
|
|
|
|
* redux.
|
2017-08-25 16:45:30 +00:00
|
|
|
* @returns {{
|
2018-05-16 14:00:16 +00:00
|
|
|
* type: RECORDING_SESSION_UPDATED,
|
|
|
|
* sessionData: Object
|
2017-08-25 16:45:30 +00:00
|
|
|
* }}
|
|
|
|
*/
|
2018-06-14 09:15:36 +00:00
|
|
|
export function updateRecordingSessionData(session: Object) {
|
2017-08-25 16:45:30 +00:00
|
|
|
return {
|
2018-05-16 14:00:16 +00:00
|
|
|
type: RECORDING_SESSION_UPDATED,
|
|
|
|
sessionData: {
|
|
|
|
error: session.getError(),
|
|
|
|
id: session.getID(),
|
|
|
|
liveStreamViewURL: session.getLiveStreamViewURL(),
|
|
|
|
mode: session.getMode(),
|
|
|
|
status: session.getStatus()
|
|
|
|
}
|
2017-08-25 16:45:30 +00:00
|
|
|
};
|
|
|
|
}
|
2018-07-05 11:17:45 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets UID of the the pending streaming notification to use it when hinding
|
|
|
|
* the notification is necessary, or unsets it when undefined (or no param) is
|
|
|
|
* passed.
|
|
|
|
*
|
|
|
|
* @param {?number} uid - The UID of the notification.
|
|
|
|
* redux.
|
|
|
|
* @param {string} streamType - The type of the stream (e.g. file or stream).
|
|
|
|
* @returns {{
|
|
|
|
* type: SET_PENDING_RECORDING_NOTIFICATION_UID,
|
|
|
|
* streamType: string,
|
|
|
|
* uid: number
|
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
function _setPendingRecordingNotificationUid(uid: ?number, streamType: string) {
|
|
|
|
return {
|
|
|
|
type: SET_PENDING_RECORDING_NOTIFICATION_UID,
|
|
|
|
streamType,
|
|
|
|
uid
|
|
|
|
};
|
|
|
|
}
|