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, download_path: string,
completed: boolean, completed: boolean,
}, },
fileInfoErrors: ?{
[string]: boolean,
},
metadata: ?{ metadata: ?{
nsfw: boolean, nsfw: boolean,
thumbnail: string, thumbnail: string,
@ -55,14 +58,17 @@ class FileViewer extends React.PureComponent<Props> {
window.addEventListener('keydown', this.handleKeyDown); window.addEventListener('keydown', this.handleKeyDown);
} }
componentWillReceiveProps(nextProps: Props) { componentDidUpdate(prev: Props) {
if ( if (
this.props.autoplay !== nextProps.autoplay || this.props.autoplay !== prev.autoplay ||
this.props.fileInfo !== nextProps.fileInfo || this.props.fileInfo !== prev.fileInfo ||
this.props.isDownloading !== nextProps.isDownloading || this.props.isDownloading !== prev.isDownloading ||
this.props.playingUri !== nextProps.playingUri 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) => { handleAutoplay = (props: Props) => {
const { const { autoplay, playingUri, fileInfo, costInfo, isDownloading, uri, play, metadata } = props;
autoplay,
playingUri,
fileInfo,
costInfo,
isDownloading,
uri,
play,
metadata,
fileInfoErrors,
} = props;
const playable = const playable = autoplay && playingUri !== uri && metadata && !metadata.nsfw;
autoplay && playingUri !== uri && metadata && !metadata.nsfw && !(uri in fileInfoErrors);
if (playable && costInfo && costInfo.cost === 0 && !fileInfo && !isDownloading) { if (playable && costInfo && costInfo.cost === 0 && !fileInfo && !isDownloading) {
play(uri); play(uri);