From: Mike Frysinger Date: Sat, 28 Sep 2013 04:35:32 +0000 (-0400) Subject: playlist/metadata: do not crash whilst connecting X-Git-Tag: v3.2~5 X-Git-Url: https://git.wh0rd.org/?p=chrome-ext%2Fmusic-player-client.git;a=commitdiff_plain;h=59f1734f1a863c8082c2a65b5f479cb6aea9651c playlist/metadata: do not crash whilst connecting If we haven't connected yet, then "mpc" won't be available. Don't kill ourselves over it. --- diff --git a/main.js b/main.js index 1466bde..266bb1e 100644 --- a/main.js +++ b/main.js @@ -157,12 +157,15 @@ function show_page(page) { if (typeof(page) != 'string') page = this.id.split('.')[1]; + // We might not be connected in which case 'mpc' will be undefined. switch (page) { case 'playlist': - mpc.playlistinfo(); + if (mpc) + mpc.playlistinfo(); // Fallthrough. case 'metadata': - mpc.currentsong(); + if (mpc) + mpc.currentsong(); break; }