suppress load video error #1768

Merged
daovist merged 6 commits from suppress-load-video-error into master 2018-07-19 16:42:24 +02:00
Showing only changes of commit bc68b75012 - Show all commits

View file

@ -17,6 +17,9 @@ type Props = {
download_path: string,
completed: boolean,
},
fileInfoErrors: ?{
[string]: boolean,
},
metadata: ?{
nsfw: boolean,
thumbnail: string,
@ -55,14 +58,17 @@ class FileViewer extends React.PureComponent<Props> {
window.addEventListener('keydown', this.handleKeyDown);
}
componentWillReceiveProps(nextProps: Props) {
componentDidUpdate(prev: Props) {
if (
this.props.autoplay !== nextProps.autoplay ||
this.props.fileInfo !== nextProps.fileInfo ||
this.props.isDownloading !== nextProps.isDownloading ||
this.props.playingUri !== nextProps.playingUri
this.props.autoplay !== prev.autoplay ||
this.props.fileInfo !== prev.fileInfo ||
this.props.isDownloading !== prev.isDownloading ||
this.props.playingUri !== prev.playingUri
) {
this.handleAutoplay(nextProps);
// suppress autoplay after download error
if (!(this.props.uri in this.props.fileInfoErrors)) {
this.handleAutoplay(this.props);
}
}
}
@ -79,22 +85,10 @@ class FileViewer extends React.PureComponent<Props> {
}
}
// do not play when state.content.errors[uri]
handleAutoplay = (props: Props) => {
const {
autoplay,
playingUri,
fileInfo,
costInfo,
isDownloading,
uri,
play,
metadata,
fileInfoErrors,
} = props;
const { autoplay, playingUri, fileInfo, costInfo, isDownloading, uri, play, metadata } = props;
const playable =
autoplay && playingUri !== uri && metadata && !metadata.nsfw && !(uri in fileInfoErrors);
const playable = autoplay && playingUri !== uri && metadata && !metadata.nsfw;
if (playable && costInfo && costInfo.cost === 0 && !fileInfo && !isDownloading) {
play(uri);