From 99afa88a36a42d3e2f2ec159adf343a980688fd9 Mon Sep 17 00:00:00 2001 From: seanyesmunt Date: Wed, 22 Aug 2018 15:54:52 -0400 Subject: [PATCH] don't record file twice if user clicked 'download' before 'play' --- src/renderer/component/fileViewer/internal/player.jsx | 1 + src/renderer/component/fileViewer/view.jsx | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/renderer/component/fileViewer/internal/player.jsx b/src/renderer/component/fileViewer/internal/player.jsx index 8d3bf07b9..d76d0bcaf 100644 --- a/src/renderer/component/fileViewer/internal/player.jsx +++ b/src/renderer/component/fileViewer/internal/player.jsx @@ -46,6 +46,7 @@ class MediaPlayer extends React.PureComponent { const loadedMetadata = () => { this.setState({ hasMetadata: true, startedPlaying: true }); + if (startedPlayingCb) { startedPlayingCb(); } diff --git a/src/renderer/component/fileViewer/view.jsx b/src/renderer/component/fileViewer/view.jsx index 57cab3463..aed32f07c 100644 --- a/src/renderer/component/fileViewer/view.jsx +++ b/src/renderer/component/fileViewer/view.jsx @@ -146,7 +146,12 @@ class FileViewer extends React.PureComponent { } playContent() { - const { play, uri } = this.props; + const { play, uri, fileInfo, isDownloading, isLoading } = this.props; + + if (fileInfo || isDownloading || isLoading) { + // User may have pressed download before clicking play + this.startedPlayingCb = null; + } if (this.startedPlayingCb) { this.startTime = Date.now();