From a1383bf7306289a34d6a4812c14c0fd9d06a0ca0 Mon Sep 17 00:00:00 2001 From: virtuacoplenny Date: Tue, 29 Jan 2019 08:22:50 -0800 Subject: [PATCH] fix(local-recording): allow config override to enable (#3615) * fix(local-recording): allow config override to enable Config overrides are not set until some time after APP_WILL_MOUNT has completed and not in the same execution context as when APP_WILL_MOUNT is called. So instead choose recording controller initialization at a later time. The time chosen is after conference join because the controller needs the conference instance to work. * remove redundant conditional check --- react/features/base/config/functions.js | 1 + react/features/local-recording/middleware.js | 34 +++++++++++--------- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/react/features/base/config/functions.js b/react/features/base/config/functions.js index 348c00284..ee752b1f8 100644 --- a/react/features/base/config/functions.js +++ b/react/features/base/config/functions.js @@ -120,6 +120,7 @@ const WHITELISTED_KEYS = [ 'iceTransportPolicy', 'ignoreStartMuted', 'liveStreamingEnabled', + 'localRecording', 'minParticipants', 'nick', 'openBridgeChannel', diff --git a/react/features/local-recording/middleware.js b/react/features/local-recording/middleware.js index 3f834c26a..8ef415b45 100644 --- a/react/features/local-recording/middleware.js +++ b/react/features/local-recording/middleware.js @@ -1,7 +1,7 @@ /* @flow */ import { createShortcutEvent, sendAnalytics } from '../analytics'; -import { APP_WILL_MOUNT, APP_WILL_UNMOUNT } from '../base/app'; +import { APP_WILL_UNMOUNT } from '../base/app'; import { CONFERENCE_JOINED } from '../base/conference'; import { toggleDialog } from '../base/dialog'; import { i18next } from '../base/i18n'; @@ -15,29 +15,23 @@ import { LocalRecordingInfoDialog } from './components'; import { recordingController } from './controller'; declare var APP: Object; -declare var config: Object; -const isFeatureEnabled = typeof config === 'object' && config.localRecording - && config.localRecording.enabled === true; - -isFeatureEnabled -&& MiddlewareRegistry.register(({ getState, dispatch }) => next => action => { +MiddlewareRegistry.register(({ getState, dispatch }) => next => action => { const result = next(action); switch (action.type) { case CONFERENCE_JOINED: { - const { conference } = getState()['features/base/conference']; const { localRecording } = getState()['features/base/config']; + const isLocalRecordingEnabled = Boolean( + localRecording + && localRecording.enabled + && typeof APP === 'object' + ); - if (localRecording && localRecording.format) { - recordingController.switchFormat(localRecording.format); + if (!isLocalRecordingEnabled) { + break; } - recordingController.registerEvents(conference); - break; - } - case APP_WILL_MOUNT: - // realize the delegates on recordingController, allowing the UI to // react to state changes in recordingController. recordingController.onStateChanged = isEngaged => { @@ -69,7 +63,17 @@ isFeatureEnabled sendAnalytics(createShortcutEvent('local.recording')); dispatch(toggleDialog(LocalRecordingInfoDialog)); }, 'keyboardShortcuts.localRecording'); + + if (localRecording.format) { + recordingController.switchFormat(localRecording.format); + } + + const { conference } = getState()['features/base/conference']; + + recordingController.registerEvents(conference); + break; + } case APP_WILL_UNMOUNT: recordingController.onStateChanged = null; recordingController.onNotify = null;