2018-06-19 16:43:33 +00:00
|
|
|
/* @flow */
|
|
|
|
|
2018-07-18 22:21:05 +00:00
|
|
|
import { createShortcutEvent, sendAnalytics } from '../analytics';
|
2020-06-04 14:09:13 +00:00
|
|
|
import { APP_WILL_UNMOUNT } from '../base/app/actionTypes';
|
|
|
|
import { CONFERENCE_JOINED } from '../base/conference/actionTypes';
|
|
|
|
import { toggleDialog } from '../base/dialog/actions';
|
2018-06-19 16:43:33 +00:00
|
|
|
import { i18next } from '../base/i18n';
|
2020-06-04 14:09:13 +00:00
|
|
|
import { SET_AUDIO_MUTED } from '../base/media/actionTypes';
|
2018-06-19 16:43:33 +00:00
|
|
|
import { MiddlewareRegistry } from '../base/redux';
|
2018-07-31 09:53:22 +00:00
|
|
|
import { SETTINGS_UPDATED } from '../base/settings/actionTypes';
|
2020-06-04 14:09:13 +00:00
|
|
|
import { showNotification } from '../notifications/actions';
|
2018-06-19 16:43:33 +00:00
|
|
|
|
2018-07-09 18:09:14 +00:00
|
|
|
import { localRecordingEngaged, localRecordingUnengaged } from './actions';
|
2018-07-18 22:12:25 +00:00
|
|
|
import { LocalRecordingInfoDialog } from './components';
|
2018-06-19 16:43:33 +00:00
|
|
|
import { recordingController } from './controller';
|
|
|
|
|
2018-07-18 22:12:25 +00:00
|
|
|
declare var APP: Object;
|
|
|
|
|
2019-01-29 16:22:50 +00:00
|
|
|
MiddlewareRegistry.register(({ getState, dispatch }) => next => action => {
|
2018-06-19 16:43:33 +00:00
|
|
|
const result = next(action);
|
|
|
|
|
|
|
|
switch (action.type) {
|
|
|
|
case CONFERENCE_JOINED: {
|
2018-07-25 14:52:11 +00:00
|
|
|
const { localRecording } = getState()['features/base/config'];
|
2019-01-29 16:22:50 +00:00
|
|
|
const isLocalRecordingEnabled = Boolean(
|
|
|
|
localRecording
|
|
|
|
&& localRecording.enabled
|
|
|
|
&& typeof APP === 'object'
|
|
|
|
);
|
2018-07-25 14:52:11 +00:00
|
|
|
|
2019-01-29 16:22:50 +00:00
|
|
|
if (!isLocalRecordingEnabled) {
|
|
|
|
break;
|
2018-07-25 14:52:11 +00:00
|
|
|
}
|
2018-06-19 16:43:33 +00:00
|
|
|
|
2018-07-09 18:09:14 +00:00
|
|
|
// realize the delegates on recordingController, allowing the UI to
|
|
|
|
// react to state changes in recordingController.
|
2018-07-18 22:29:24 +00:00
|
|
|
recordingController.onStateChanged = isEngaged => {
|
2018-07-09 18:09:14 +00:00
|
|
|
if (isEngaged) {
|
2018-07-10 14:26:16 +00:00
|
|
|
const nowTime = new Date();
|
|
|
|
|
|
|
|
dispatch(localRecordingEngaged(nowTime));
|
2018-07-09 18:09:14 +00:00
|
|
|
} else {
|
|
|
|
dispatch(localRecordingUnengaged());
|
|
|
|
}
|
2018-06-19 16:43:33 +00:00
|
|
|
};
|
|
|
|
|
2018-07-18 22:21:05 +00:00
|
|
|
recordingController.onWarning = (messageKey, messageParams) => {
|
2018-06-19 16:43:33 +00:00
|
|
|
dispatch(showNotification({
|
|
|
|
title: i18next.t('localRecording.localRecording'),
|
2018-07-16 05:10:15 +00:00
|
|
|
description: i18next.t(messageKey, messageParams)
|
2018-06-19 16:43:33 +00:00
|
|
|
}, 10000));
|
|
|
|
};
|
|
|
|
|
2018-07-18 22:21:05 +00:00
|
|
|
recordingController.onNotify = (messageKey, messageParams) => {
|
2018-06-19 16:43:33 +00:00
|
|
|
dispatch(showNotification({
|
|
|
|
title: i18next.t('localRecording.localRecording'),
|
2018-07-16 05:10:15 +00:00
|
|
|
description: i18next.t(messageKey, messageParams)
|
2018-06-19 16:43:33 +00:00
|
|
|
}, 10000));
|
|
|
|
};
|
2018-07-18 22:12:25 +00:00
|
|
|
|
2018-08-01 01:43:56 +00:00
|
|
|
typeof APP === 'object' && typeof APP.keyboardshortcut === 'object'
|
|
|
|
&& APP.keyboardshortcut.registerShortcut('L', null, () => {
|
|
|
|
sendAnalytics(createShortcutEvent('local.recording'));
|
|
|
|
dispatch(toggleDialog(LocalRecordingInfoDialog));
|
|
|
|
}, 'keyboardShortcuts.localRecording');
|
2019-01-29 16:22:50 +00:00
|
|
|
|
|
|
|
if (localRecording.format) {
|
|
|
|
recordingController.switchFormat(localRecording.format);
|
|
|
|
}
|
|
|
|
|
|
|
|
const { conference } = getState()['features/base/conference'];
|
|
|
|
|
|
|
|
recordingController.registerEvents(conference);
|
|
|
|
|
2018-06-19 16:43:33 +00:00
|
|
|
break;
|
2019-01-29 16:22:50 +00:00
|
|
|
}
|
2018-06-19 16:43:33 +00:00
|
|
|
case APP_WILL_UNMOUNT:
|
|
|
|
recordingController.onStateChanged = null;
|
|
|
|
recordingController.onNotify = null;
|
|
|
|
recordingController.onWarning = null;
|
|
|
|
break;
|
2018-07-25 14:52:11 +00:00
|
|
|
case SET_AUDIO_MUTED:
|
|
|
|
recordingController.setMuted(action.muted);
|
|
|
|
break;
|
2018-07-31 09:53:22 +00:00
|
|
|
case SETTINGS_UPDATED: {
|
|
|
|
const { micDeviceId } = getState()['features/base/settings'];
|
2018-06-19 16:43:33 +00:00
|
|
|
|
2018-07-31 09:53:22 +00:00
|
|
|
if (micDeviceId) {
|
|
|
|
recordingController.setMicDevice(micDeviceId);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2018-07-09 17:49:55 +00:00
|
|
|
|
2018-06-19 16:43:33 +00:00
|
|
|
return result;
|
|
|
|
});
|