jiti-meet/react/features/shared-video/components/AbstractSharedVideoDialog.js

67 lines
1.4 KiB
JavaScript
Raw Normal View History

2020-06-12 10:15:16 +00:00
// @flow
import { Component } from 'react';
import type { Dispatch } from 'redux';
/**
* The type of the React {@code Component} props of
* {@link AbstractSharedVideoDialog}.
2020-06-12 10:15:16 +00:00
*/
export type Props = {
/**
* Invoked to update the shared video link.
2020-06-12 10:15:16 +00:00
*/
dispatch: Dispatch<any>,
/**
* Function to be invoked after typing a valid video.
*/
onPostSubmit: Function,
/**
* Invoked to obtain translated strings.
2020-06-12 10:15:16 +00:00
*/
t: Function
2020-06-12 10:15:16 +00:00
};
/**
* Implements an abstract class for {@code SharedVideoDialog}.
2020-06-12 10:15:16 +00:00
*/
export default class AbstractSharedVideoDialog<S: *> extends Component < Props, S > {
2020-06-12 10:15:16 +00:00
/**
* Instantiates a new component.
*
* @inheritdoc
*/
constructor(props: Props) {
super(props);
this._onSetVideoLink = this._onSetVideoLink.bind(this);
}
_onSetVideoLink: string => boolean;
/**
* Validates the entered video link by extracting the id and dispatches it.
2020-06-12 10:15:16 +00:00
*
* It returns a boolean to comply the Dialog behaviour:
* {@code true} - the dialog should be closed.
* {@code false} - the dialog should be left open.
*
* @param {string} link - The entered video link.
* @returns {boolean}
*/
_onSetVideoLink(link: string) {
2020-06-12 10:15:16 +00:00
if (!link || !link.trim()) {
return false;
}
const { onPostSubmit } = this.props;
2020-06-12 10:15:16 +00:00
onPostSubmit(link);
2020-06-12 10:15:16 +00:00
return true;
2020-06-12 10:15:16 +00:00
}
}