mirror of
https://gitcode.com/GitHub_Trending/ji/jitsi-meet.git
synced 2026-01-06 14:52:28 +00:00
feat(shared-video) refactor dialog to use React
Also unify the mobile and web features into one, even though internally they still have separate ways to enable the functionality.
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
// @flow
|
||||
|
||||
import { Component } from 'react';
|
||||
import type { Dispatch } from 'redux';
|
||||
|
||||
import { getYoutubeLink } from '../functions';
|
||||
|
||||
|
||||
/**
|
||||
* The type of the React {@code Component} props of
|
||||
* {@link AbstractSharedVideoDialog}.
|
||||
*/
|
||||
export type Props = {
|
||||
|
||||
/**
|
||||
* Invoked to update the shared video link.
|
||||
*/
|
||||
dispatch: Dispatch<any>,
|
||||
|
||||
/**
|
||||
* Function to be invoked after typing a valid video.
|
||||
*/
|
||||
onPostSubmit: ?Function,
|
||||
|
||||
/**
|
||||
* Invoked to obtain translated strings.
|
||||
*/
|
||||
t: Function
|
||||
};
|
||||
|
||||
/**
|
||||
* Implements an abstract class for {@code SharedVideoDialog}.
|
||||
*/
|
||||
export default class AbstractSharedVideoDialog<S: *> extends Component < Props, S > {
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* 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) {
|
||||
if (!link || !link.trim()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const videoId = getYoutubeLink(link);
|
||||
|
||||
if (videoId) {
|
||||
const { onPostSubmit } = this.props;
|
||||
|
||||
onPostSubmit && onPostSubmit(videoId);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user