fix(recording): Respect the selected recording service.

This commit is contained in:
Hristo Terezov 2019-03-15 19:28:26 +00:00 committed by Дамян Минков
parent f5a7e0bccb
commit a6719896a2
4 changed files with 107 additions and 41 deletions

View File

@ -64,6 +64,11 @@ type State = {
*/ */
isValidating: boolean, isValidating: boolean,
/**
* The currently selected recording service of type: RECORDING_TYPES.
*/
selectedRecordingService: ?string,
/** /**
* Number of MiB of available space in user's Dropbox account. * Number of MiB of available space in user's Dropbox account.
*/ */
@ -89,15 +94,27 @@ class AbstractStartRecordingDialog extends Component<Props, State> {
// Bind event handler so it is only bound once for every instance. // Bind event handler so it is only bound once for every instance.
this._onSubmit = this._onSubmit.bind(this); this._onSubmit = this._onSubmit.bind(this);
this._onSelectedRecordingServiceChanged
= this._onSelectedRecordingServiceChanged.bind(this);
let selectedRecordingService;
// TODO: Potentially check if we need to handle changes of
// _fileRecordingsServiceEnabled and _areIntegrationsEnabled()
if (this.props._fileRecordingsServiceEnabled
|| !this._areIntegrationsEnabled()) {
selectedRecordingService = RECORDING_TYPES.JITSI_REC_SERVICE;
} else if (this._areIntegrationsEnabled()) {
selectedRecordingService = RECORDING_TYPES.DROPBOX;
}
this.state = { this.state = {
isTokenValid: false, isTokenValid: false,
isValidating: false, isValidating: false,
userName: undefined, userName: undefined,
spaceLeft: undefined spaceLeft: undefined,
selectedRecordingService
}; };
this._onSubmit = this._onSubmit.bind(this);
} }
/** /**
@ -124,6 +141,32 @@ class AbstractStartRecordingDialog extends Component<Props, State> {
} }
} }
_areIntegrationsEnabled: () => boolean;
/**
* Returns true if the integrations with third party services are enabled
* and false otherwise.
*
* @returns {boolean} - True if the integrations with third party services
* are enabled and false otherwise.
*/
_areIntegrationsEnabled() {
return this.props._isDropboxEnabled;
}
_onSelectedRecordingServiceChanged: (string) => void;
/**
* Handles selected recording service changes.
*
* @param {string} selectedRecordingService - The new selected recording
* service.
* @returns {void}
*/
_onSelectedRecordingServiceChanged(selectedRecordingService) {
this.setState({ selectedRecordingService });
}
/** /**
* Validates the dropbox access token and fetches account information. * Validates the dropbox access token and fetches account information.
* *
@ -176,7 +219,10 @@ class AbstractStartRecordingDialog extends Component<Props, State> {
let appData; let appData;
const attributes = {}; const attributes = {};
if (_isDropboxEnabled && _token) { if (_isDropboxEnabled
&& _token
&& this.state.selectedRecordingService
=== RECORDING_TYPES.DROPBOX) {
appData = JSON.stringify({ appData = JSON.stringify({
'file_recording_metadata': { 'file_recording_metadata': {
'upload_credentials': { 'upload_credentials': {

View File

@ -64,6 +64,17 @@ type Props = {
*/ */
isValidating: boolean, isValidating: boolean,
/**
* The function will be called when there are changes related to the
* switches.
*/
onChange: Function,
/**
* The currently selected recording service of type: RECORDING_TYPES.
*/
selectedRecordingService: ?string,
/** /**
* Number of MiB of available space in user's Dropbox account. * Number of MiB of available space in user's Dropbox account.
*/ */
@ -77,27 +88,15 @@ type Props = {
/** /**
* The display name of the user's Dropbox account. * The display name of the user's Dropbox account.
*/ */
userName: ?string, userName: ?string
}; };
/**
* State of the component.
*/
type State = {
/**
* The currently selected recording service of type: RECORDING_TYPES.
*/
selectedRecordingService: string
};
/** /**
* React Component for getting confirmation to start a file recording session. * React Component for getting confirmation to start a file recording session.
* *
* @extends Component * @extends Component
*/ */
class StartRecordingDialogContent extends Component<Props, State> { class StartRecordingDialogContent extends Component<Props> {
/** /**
* Initializes a new {@code StartRecordingDialogContent} instance. * Initializes a new {@code StartRecordingDialogContent} instance.
* *
@ -113,12 +112,6 @@ class StartRecordingDialogContent extends Component<Props, State> {
= this._onDropboxSwitchChange.bind(this); = this._onDropboxSwitchChange.bind(this);
this._onRecordingServiceSwitchChange this._onRecordingServiceSwitchChange
= this._onRecordingServiceSwitchChange.bind(this); = this._onRecordingServiceSwitchChange.bind(this);
// the initial state is jitsi rec service is always selected
// if only one type of recording is enabled this state will be ignored
this.state = {
selectedRecordingService: RECORDING_TYPES.JITSI_REC_SERVICE
};
} }
/** /**
@ -165,7 +158,7 @@ class StartRecordingDialogContent extends Component<Props, State> {
style = { styles.switch } style = { styles.switch }
trackColor = {{ false: ColorPalette.lightGrey }} trackColor = {{ false: ColorPalette.lightGrey }}
value = { value = {
this.state.selectedRecordingService this.props.selectedRecordingService
=== RECORDING_TYPES.JITSI_REC_SERVICE } /> === RECORDING_TYPES.JITSI_REC_SERVICE } />
) : null; ) : null;
@ -243,7 +236,7 @@ class StartRecordingDialogContent extends Component<Props, State> {
onValueChange = { this._onDropboxSwitchChange } onValueChange = { this._onDropboxSwitchChange }
style = { styles.switch } style = { styles.switch }
trackColor = {{ false: ColorPalette.lightGrey }} trackColor = {{ false: ColorPalette.lightGrey }}
value = { this.state.selectedRecordingService value = { this.props.selectedRecordingService
=== RECORDING_TYPES.DROPBOX } /> === RECORDING_TYPES.DROPBOX } />
); );
} }
@ -287,18 +280,21 @@ class StartRecordingDialogContent extends Component<Props, State> {
* @returns {void} * @returns {void}
*/ */
_onRecordingServiceSwitchChange() { _onRecordingServiceSwitchChange() {
const {
isTokenValid,
onChange,
selectedRecordingService
} = this.props;
// act like group, cannot toggle off // act like group, cannot toggle off
if (this.state.selectedRecordingService if (selectedRecordingService
=== RECORDING_TYPES.JITSI_REC_SERVICE) { === RECORDING_TYPES.JITSI_REC_SERVICE) {
return; return;
} }
this.setState({ onChange(RECORDING_TYPES.JITSI_REC_SERVICE);
selectedRecordingService: RECORDING_TYPES.JITSI_REC_SERVICE
});
if (this.props.isTokenValid) { if (isTokenValid) {
this._onSignOut(); this._onSignOut();
} }
} }
@ -309,17 +305,21 @@ class StartRecordingDialogContent extends Component<Props, State> {
* @returns {void} * @returns {void}
*/ */
_onDropboxSwitchChange() { _onDropboxSwitchChange() {
const {
isTokenValid,
onChange,
selectedRecordingService
} = this.props;
// act like group, cannot toggle off // act like group, cannot toggle off
if (this.state.selectedRecordingService if (selectedRecordingService
=== RECORDING_TYPES.DROPBOX) { === RECORDING_TYPES.DROPBOX) {
return; return;
} }
this.setState({ onChange(RECORDING_TYPES.DROPBOX);
selectedRecordingService: RECORDING_TYPES.DROPBOX
});
if (!this.props.isTokenValid) { if (!isTokenValid) {
this._onSignIn(); this._onSignIn();
} }
} }

View File

@ -24,7 +24,13 @@ class StartRecordingDialog extends AbstractStartRecordingDialog {
* @inheritdoc * @inheritdoc
*/ */
render() { render() {
const { isTokenValid, isValidating, spaceLeft, userName } = this.state; const {
isTokenValid,
isValidating,
selectedRecordingService,
spaceLeft,
userName
} = this.state;
const { _fileRecordingsServiceEnabled, _isDropboxEnabled } = this.props; const { _fileRecordingsServiceEnabled, _isDropboxEnabled } = this.props;
// disable ok button id recording service is shown only, when // disable ok button id recording service is shown only, when
@ -42,16 +48,20 @@ class StartRecordingDialog extends AbstractStartRecordingDialog {
<StartRecordingDialogContent <StartRecordingDialogContent
fileRecordingsServiceEnabled fileRecordingsServiceEnabled
= { _fileRecordingsServiceEnabled } = { _fileRecordingsServiceEnabled }
integrationsEnabled = { _isDropboxEnabled } integrationsEnabled = { this._areIntegrationsEnabled() }
isTokenValid = { isTokenValid } isTokenValid = { isTokenValid }
isValidating = { isValidating } isValidating = { isValidating }
onChange = { this._onSelectedRecordingServiceChanged }
selectedRecordingService = { selectedRecordingService }
spaceLeft = { spaceLeft } spaceLeft = { spaceLeft }
userName = { userName } /> userName = { userName } />
</CustomSubmitDialog> </CustomSubmitDialog>
); );
} }
_areIntegrationsEnabled: () => boolean;
_onSubmit: () => boolean _onSubmit: () => boolean
_onSelectedRecordingServiceChanged: (string) => void;
} }
export default translate(connect(mapStateToProps)(StartRecordingDialog)); export default translate(connect(mapStateToProps)(StartRecordingDialog));

View File

@ -24,7 +24,13 @@ class StartRecordingDialog extends AbstractStartRecordingDialog {
* @inheritdoc * @inheritdoc
*/ */
render() { render() {
const { isTokenValid, isValidating, spaceLeft, userName } = this.state; const {
isTokenValid,
isValidating,
selectedRecordingService,
spaceLeft,
userName
} = this.state;
const { _fileRecordingsServiceEnabled, _isDropboxEnabled } = this.props; const { _fileRecordingsServiceEnabled, _isDropboxEnabled } = this.props;
// disable ok button id recording service is shown only, when // disable ok button id recording service is shown only, when
@ -45,16 +51,20 @@ class StartRecordingDialog extends AbstractStartRecordingDialog {
<StartRecordingDialogContent <StartRecordingDialogContent
fileRecordingsServiceEnabled fileRecordingsServiceEnabled
= { _fileRecordingsServiceEnabled } = { _fileRecordingsServiceEnabled }
integrationsEnabled = { _isDropboxEnabled } integrationsEnabled = { this._areIntegrationsEnabled() }
isTokenValid = { isTokenValid } isTokenValid = { isTokenValid }
isValidating = { isValidating } isValidating = { isValidating }
onChange = { this._onSelectedRecordingServiceChanged }
selectedRecordingService = { selectedRecordingService }
spaceLeft = { spaceLeft } spaceLeft = { spaceLeft }
userName = { userName } /> userName = { userName } />
</Dialog> </Dialog>
); );
} }
_onSubmit: () => boolean _areIntegrationsEnabled: () => boolean;
_onSubmit: () => boolean;
_onSelectedRecordingServiceChanged: (string) => void;
} }
export default translate(connect(mapStateToProps)(StartRecordingDialog)); export default translate(connect(mapStateToProps)(StartRecordingDialog));