code review

This commit is contained in:
Tudor-Ovidiu Avram
2021-05-13 14:36:19 +03:00
parent 4e4ff0f60f
commit 3ebfb1de70
10 changed files with 78 additions and 53 deletions

View File

@@ -9,6 +9,7 @@ import { connect } from '../../../base/redux';
import { ASPECT_RATIO_WIDE } from '../../../base/responsive-ui';
import { setToolboxVisible } from '../../../toolbox/actions';
import { setSharedVideoStatus } from '../../actions.native';
import { getYoutubeId } from '../../functions';
import styles from './styles';
@@ -100,11 +101,11 @@ type Props = {
dispatch: Function,
/**
* Youtube id of the video to be played.
* Youtube url of the video to be played.
*
* @private
*/
youtubeId: string
youtubeUrl: string
};
/**
@@ -199,7 +200,7 @@ class YoutubeLargeVideo extends Component<Props, *> {
_isPlaying,
_playerHeight,
_playerWidth,
youtubeId
youtubeUrl
} = this.props;
return (
@@ -220,7 +221,7 @@ class YoutubeLargeVideo extends Component<Props, *> {
play = { _isPlaying }
playbackRate = { 1 }
ref = { this.playerRef }
videoId = { youtubeId }
videoId = { getYoutubeId(youtubeUrl) }
volume = { 50 }
webViewProps = {{
bounces: false,
@@ -243,7 +244,7 @@ class YoutubeLargeVideo extends Component<Props, *> {
_onReady() {
if (this.props?._isOwner) {
this.onVideoReady(
this.props.youtubeId,
this.props.youtubeUrl,
this.playerRef.current && this.playerRef.current.getCurrentTime(),
this.props._ownerId);
}
@@ -266,11 +267,11 @@ class YoutubeLargeVideo extends Component<Props, *> {
_isStopped,
_ownerId,
_seek,
youtubeId
youtubeUrl
} = this.props;
if (shouldSetNewStatus(_isStopped, _isOwner, status, _isPlaying, time, _seek)) {
this.onVideoChangeEvent(youtubeId, status, time, _ownerId);
this.onVideoChangeEvent(youtubeUrl, status, time, _ownerId);
}
});
}
@@ -282,10 +283,10 @@ class YoutubeLargeVideo extends Component<Props, *> {
* @returns {void}
*/
saveRefTime() {
const { youtubeId, _status, _ownerId } = this.props;
const { youtubeUrl, _status, _ownerId } = this.props;
this.playerRef.current && this.playerRef.current.getCurrentTime().then(time => {
this.onVideoChangeEvent(youtubeId, _status, time, _ownerId);
this.onVideoChangeEvent(youtubeUrl, _status, time, _ownerId);
});
}