From 8081d42477c1422366d88cc8c1e4ff4bcba58cca Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Wed, 5 Oct 2016 02:14:22 -0700 Subject: [PATCH] Attempt to fix "TypeError: Cannot read property 'startPiece' of undefined" It wasn't clear what was causing this error, and I couldn't reproduce it. This PR attempts to resolve the issue by just guarding against the exception. --- src/renderer/pages/player-page.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/renderer/pages/player-page.js b/src/renderer/pages/player-page.js index 6db4d6bf..1574ee17 100644 --- a/src/renderer/pages/player-page.js +++ b/src/renderer/pages/player-page.js @@ -599,12 +599,15 @@ function renderLoadingBar (state) { const torrentSummary = state.getPlayingTorrentSummary() if (!torrentSummary.progress) { - return [] + return null } // Find all contiguous parts of the torrent which are loaded const prog = torrentSummary.progress const fileProg = prog.files[state.playing.fileIndex] + + if (!fileProg) return null + const parts = [] let lastPiecePresent = false for (let i = fileProg.startPiece; i <= fileProg.endPiece; i++) { @@ -626,6 +629,7 @@ function renderLoadingBar (state) { return (
) }) + return (
{loadingBarElems}
) }