From 59f1734f1a863c8082c2a65b5f479cb6aea9651c Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Sat, 28 Sep 2013 00:35:32 -0400 Subject: [PATCH] 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. --- main.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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; } -- 2.39.5