From aa56d875c0df4587107a68d46208773943ee7d72 Mon Sep 17 00:00:00 2001 From: Jordan Eldredge Date: Tue, 24 Oct 2017 20:31:53 -0700 Subject: [PATCH] Guard against accessing file that does not exist. --- js/components/MainWindow/index.js | 5 +++-- js/winamp.js | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/js/components/MainWindow/index.js b/js/components/MainWindow/index.js index 3f8c6c45..ee96bd0a 100644 --- a/js/components/MainWindow/index.js +++ b/js/components/MainWindow/index.js @@ -51,8 +51,9 @@ export class MainWindow extends React.Component { handleDrop(e) { this.supress(e); const { files } = e.dataTransfer; - // TODO: Move this to an actionCreator - this.props.loadFileFromReference(files[0]); + if (files[0]) { + this.props.loadFileFromReference(files[0]); + } } render() { diff --git a/js/winamp.js b/js/winamp.js index a346c15f..508faa75 100644 --- a/js/winamp.js +++ b/js/winamp.js @@ -34,7 +34,9 @@ class Winamp { ); this.fileInput.addEventListener("change", e => { - this.store.dispatch(loadFileFromReference(e.target.files[0])); + if (e.target.files[0]) { + this.store.dispatch(loadFileFromReference(e.target.files[0])); + } }); if (this.options.initialTrack && this.options.initialTrack.url) {