]> git.wh0rd.org Git - chrome-ext/music-player-client.git/commitdiff
playlist/metadata: do not crash whilst connecting
authorMike Frysinger <vapier@gentoo.org>
Sat, 28 Sep 2013 04:35:32 +0000 (00:35 -0400)
committerMike Frysinger <vapier@gentoo.org>
Sat, 28 Sep 2013 04:35:32 +0000 (00:35 -0400)
If we haven't connected yet, then "mpc" won't be available.
Don't kill ourselves over it.

main.js

diff --git a/main.js b/main.js
index 1466bded59d7192b0a094b2c4bea70254d47cb39..266bb1e60f6b242ff3108ae858d3d9322281f9b2 100644 (file)
--- 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;
        }